Hi,
I'm trying to understand how pointers work. It seems I can deference and sometimes I cannot.
If you notice I'm passing a pointer to fprintf. This doesn't compile and the error is "expecting FILE type". But "f" was declared as FILE type to begin with.Code:main(int argc, char *argv[]) { FILE *f = fopen("/home/9three/Desktop/test.txt", "a"); if (f == NULL) { printf("Unable to open file for writting."); return 1; } fprintf(*f, "Testing..\n"); return 0; }
So "f" is a pointer and variable at the same time? If I pass *f then I'm passing a pointer. But if I pass "f" then I'm just passing a variable with a specific type? eehhh.. what?