Files - a question ??

why do you need to create a file pointer initially ??
( say , we declare the file pointer as:
FILE *fp;
fp=fopen(“filename”,“mode”); )

So my question here is why do we declare a file pointer “*fp” in d beggining instead of declaring it simply as " FILE fp ; " ???

If I understood your question correctly, you are asking why you have to use FILE*? If so, it’s simply because this is a return value from fopen - see http://www.cplusplus.com/reference/cstdio/fopen/

1 Like

FILE is some kind of structure that holds information about the file. We must use a **FILE *** because certain functions will need to change that information, i.e., we need to pass the information around by reference…