I'm currently trying to wrap my head around pointers to C based on interfaces, which is not an easy task. I follow this tutorial and everything works smoothly until I try to compile the following example:
int main(int argc, char *argv[]) {
int **ramon;
int *paul;
int melissa = 5;
paul = &melissa;
ramon = &paul;
printf("ramon = %d\n", ramon); // <- warning: format '%d' expects type 'int'...
printf("&paul = %d\n", &paul); // <- warning: format '%d' expects type 'int'...
printf("*ramon = %d\n", *ramon); // <- warning: format '%d' expects type 'int'...
printf("&melissa = %d\n", &melissa); <- warning: format '%d' expects type 'int'...
printf("**ramon = %d\n", **ramon);p1); <- warning: format '%d' expects type 'int'...
return(0);
}
From the first line of printf I get this error: "warning: format"% d "expects type" int ", but argument 2 is of type" int ** ""
I believe that this is due to the way I initialize my pointers, but standing at the bottom of a steep learning curve, I don’t know how to move forward. What's wrong, how do I initialize pointers to avoid warnings?
timkl source
share