I was playing around with C, anyways I was thinking how can file pointer (which points to a struct type), be tested if NULL as for instant:
FILE *cfPtr;
if ( ( cfPtr = fopen( "file.dat", "w" ) ) == NULL )
I tried to do that myself, but an error occurs.
struct foo{
int x;
};
struct foo bar = {0};
if (bar == NULL)
puts("Yay\n");
else
puts("Nay");
error C2088: '==' : illegal for struct
Here's the FILE deceleration in the stdio.h file:
struct _iobuf {
char *_ptr;
int _cnt;
char *_base;
int _flag;
int _file;
int _charbuf;
int _bufsiz;
char *_tmpfname;
};
typedef struct _iobuf FILE;