12-06-2009 09:51 PM
Ok im trying using the pointer in another file, how can I do it?
in the main file its declared as FILE *fileptr={0}
will I do this FILE extern *fileptr in the main file
and the othe file where i want to use it will i just char *fileptr={0};
how will i do this using extern with FILE pointer
12-07-2009 04:41 AM
You probably have a common header file for your application - add the following line to it:
extern FILE *fileptr;
All your source files will of course #include this common header file. In just one of your source files, you need to actually declare the object, initialising it as well if you like:
FILE *fileptr = NULL;
The variable is now available to be used by all the source files that #include the header file. Of course, your sequence of execution needs to guarantee that the value of the variable is set correctly before any module reads it.
JR
12-07-2009 07:42 AM