2017-12-27 582 views
-5

我不知道如何解决和需要帮助的错误是:似乎无法理解C程序今仅存错误

在第20行和列28

[错误]不能转换 '诠释**' 到 'INT *' 的参数 '1' 到 '空隙 乐透(INT *,INT,INT,INT,INT,INT)'

在的这部分代码:

#include <stdio.h> 
    #include <stdlib.h> 

    int read1(); 
    int even1(); 
    int even2(); 
    int sum1(); 
    int sum2(); 
    void lotto(int*, int, int, int, int, int); 
    int* table_num(int); 

    int main() 
    { 
     int a=read1(); 
     int* t = table_num(a); 
     int x=even1(); 
     int y=even2(); 
     int g=sum1(); 
     int h=sum2(); 
     lotto(&t, a, x, y, g, h); /*error here*/ 
     return 0; 
    } 

这里是功能:

void lotto(int* a, int n, int armax, int armin, int atmax, int atmin) 
{ 
    int q, w, z=1; 

    for (int i = 0; i < n-5; ++i) 
    { 
     for (int j = i+1; j < n-4 ; ++j) 
     { 
      for (int k = j+1; k < n-3 ; ++k) 
      { 
       for (int l = k+1; l < n-2 ; ++l) 
       { 
        for (int m = l+1; m < n-1 ; ++m) 
        { 
         for (int i1 = m+1; i1 < n; ++i1) 
         { 

          q=0; 

          (i%2==0)?q+=1:2; 
          (j%2==0)?q+=1:2; 
          (k%2==0)?q+=1:2; 
          (l%2==0)?q+=1:2; 
          (m%2==0)?q+=1:2; 
          (i1%2==0)?q+=1:2; 

          w=i+j+k+l+m+i1; 

          if((q<=armax||q>=armin)&&(w>=atmin||w<=atmax)) 
          { 

           printf("The %d st/nd/rd/th group of 6 numbers is :\t",z); 
           printf("%d ,%d ,%d ,%d ,%d ,%d \n\n",*(a+i), *(a+j), *(a+k), *(a+l), *(a+m), (a+i1)); 
           z++; 

          }else 
           continue; 



         } 

        } 

       } 

      } 

     } 

    } 

} 

,如果你想需要整个代码回答我的问题,我可以在

+0

指针变量的地址是双指针 - 意思是**。 – coderredoc

+0

取代这个lotto(&t,a,x,y,g,h);乐透(t,a,x,y,g,h); – Pirate

回答

1

编辑替换该lotto(&t, a, x, y, g, h);lotto(t, a, x, y, g, h);

在函数声明中,你提到输入参数为,指向int,bu t再次通过指向指向int的指针并且导致错误。

+0

这使它的工作,但现在它不显示我想要的数字(我给了6组数字),它显示随机数字(内存位置,因为我删除&) –

+0

然后检查您的代码。可能是您正在访问没有任何内容或初始化的位置的值。 – Pirate

1

问题是'& t'在你指定'int *'的lotto()中并发送'int **'。尝试编译没有'&'

+0

,它使它工作,但现在它不显示我想要的数字(我给了6个数字的组),它显示随机数(自从我删除&以后的内存位置) –