You need to exit the function/program if you can't open the file:
Code:
FILE *fp=fopen("data00","r");
if( ! fp )
{
//RED_ERR("unable to open name of locker file\n");
printf("unable to open name of locker file\n");
// if you don't return from the function or exit the program, then your program will try to read
// from fp, which is invalid, and the program will likely crash
}
sName and sLine can't point to the same buffer. Just declare them each as their own array/buffer, like so:
Code:
char sLine[256];
char sName[256];
You can not use %a[. That is invalid. You just want %[, so
Code:
fscanf(fp, ":%[^:]:%[^:]:%d", sName, sName, iLine);
Note that there is no a in there. There is also no & in front of sName. sFile should be just like sName: no a and no &. iLine is fine the way it is.
Regarding C99: this shouldn't matter once you get rid of the a from your format specifier.