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

后端 未结 4 2727
既然无缘
既然无缘 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条回答
  •  渐次进展
    2020-12-24 14:05

    Barebones C program to produce the above error:

    #include 
    using namespace std;
    int main(){
        char *p;
        *p = 'c';
    
        cout << *p[0];  
        //error: invalid type argument of `unary *'
        //peeking too deeply into p, that's a paddlin.
    
        cout << **p;    
        //error: invalid type argument of `unary *'
        //peeking too deeply into p, you better believe that's a paddlin.
    }
    

    ELI5:

    The master puts a shiny round stone inside a small box and gives it to a student. The master says: "Open the box and remove the stone". The student does so.

    Then the master says: "Now open the stone and remove the stone". The student said: "I can't open a stone".

    The student was then enlightened.

提交回复
热议问题