Let’s say that I have a variable
char filename[12] = "xxxxxxxx.xxx";
and a function who opens a file.
void OpenFile( char *fname)
{
FILE *f;
f = fopen(fname,"w"
;
if( f == NULL )
{
printf( "File could not be opened\n" );
exit(1);
}
/* Follows code that reads from the file */
}
How do I must write the previous function and what she has to return (instead of void) so in other function I can use the same file that is already open. What arguments must I pass to the other function?
Let me be more precise, I want to write a function that reads a part of the file, another function that reads from that point forward a.s.o.
Thank you
P.S. No polemics please, just straight answers (if possible)
char filename[12] = "xxxxxxxx.xxx";
and a function who opens a file.
void OpenFile( char *fname)
{
FILE *f;
f = fopen(fname,"w"
if( f == NULL )
{
printf( "File could not be opened\n" );
exit(1);
}
/* Follows code that reads from the file */
}
How do I must write the previous function and what she has to return (instead of void) so in other function I can use the same file that is already open. What arguments must I pass to the other function?
Let me be more precise, I want to write a function that reads a part of the file, another function that reads from that point forward a.s.o.
Thank you
P.S. No polemics please, just straight answers (if possible)