Using code tags in the forum will help us (and you) read these sorts of things more easily.
Since compilers differ widely in their initialization of declared variables, it is always good practice to initialize them, and to always check and/or assign them when they are used.
For example:
Code:
FILE *fp = NULL;
if(fp == NULL)
fp = fopen(/* ... */);
if(fp == NULL)
/* error handler */
else
/* do the work */
fclose(fp);
fp = NULL;
In general:
-- when you declare a variable, initialize it (or, at least, initialize it as early as possible)
-- before you use a potentially NULL or otherwise uninitialized variable, check its state
-- when you perform an action that may leave the variable in an undetermined state, initialize it to a known state
This is always good programming practice and will save you aggravation and confusion.