This will compile...
Code:
#include <stdio.h>
struct myfile {
FILE *myPtr;
};
int main( int argc, char **argv )
{
struct myfile file;
file.myPtr = fopen( "myfile.txt", "a" );
fclose( file.myPtr );
return 0;
}
Or if you really want a pointer to a structure,
Code:
#include <stdio.h>
#include <stdlib.h>
struct myfile {
FILE *myPtr;
};
int main( int argc, char **argv )
{
struct myfile *file;
file = ( struct myfile * )malloc( sizeof( struct myfile ) );
if ( file != NULL ) {
file->myPtr = fopen( "myfile.txt", "a" );
/* do something */
fclose( file->myPtr );
free( file );
}
return 0;
}