Can anyone help with the understanding of a couple questions?
Just learning C and so we haven't got to pointers.
int flag = 1; //file closed
if((file = fopen("somefile.dat", "r"))=NULL)
printf("somefile will not open.");
else flag = 2; //file opened
1) If this is opened, it returns a pointer, but I don't really understand what that does?
2) Our book or prof doesn't really talk about the flag except to say to do it like this. I have seen it done a lot without the else condition. Can anyone help explain about the flag and else condition and if it is needed.
Sorry about no code tags, I tried to use them. Thanks