error: invalid type argument of ‘unary *’ (have ‘int’)

后端 未结 4 2710
既然无缘
既然无缘 2020-12-24 13:27

I have a C Program:

#include 
int main(){
  int b = 10;             //assign the integer 10 to variable \'b\'

  int *a;                 //dec         


        
4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-24 13:59

    Since c is holding the address of an integer pointer, its type should be int**:

    int **c;
    c = &a;
    

    The entire program becomes:

    #include                                                               
    int main(){
        int b=10;
        int *a;
        a=&b;
        int **c;
        c=&a;
        printf("%d",(**c));   //successfully prints 10
        return 0;
    }
    

提交回复
热议问题