06 May, 2009, Kober wrote in the 1st comment:
Votes: 0
void load_class (int num)
{
char buf[MAX_STRING_LENGTH];
int level,n;
FILE *fp;

sprintf (buf, "%s%s", CLASS_DIR, class_table[num].name);

if (!(fp = fopen (buf, "r")))
{
/* bugf ("Could not open file %s in order to load class %s.",
buf, class_table[num].name); */
return;
}

fscanf (fp, "%d", &level);

while (level != -1)
{
fscanf (fp, " %[^\n]\n", buf); /* read name of skill into buf */

n = skill_lookup (buf); /* find index */

if (n == -1)
{
char buf2[200];
sprintf (buf2, "Class %s: unknown spell %s", class_table[num].name, buf);
bug (buf2, 0);
}
else
skill_table[n].skill_level[num] = level;

fscanf (fp, "%d", &level);
}

fclose (fp);
}


Gives me these warnings
class.c:74: warning: ignoring return value of 'fscanf', declared with attribute warn_unused_result
class.c:78: warning: ignoring return value of 'fscanf', declared with attribute warn_unused_result
class.c:92: warning: ignoring return value of 'fscanf', declared with attribute warn_unused_result


Any help please?
06 May, 2009, David Haley wrote in the 2nd comment:
Votes: 0
It's telling you that you should be checking the return value of fscanf (for instance, to see if there was an error). Run 'man fscanf' to see the documentation for the function and the meaning of the return values.
06 May, 2009, Kober wrote in the 3rd comment:
Votes: 0
Would that make n always equal -1?
06 May, 2009, Zeno wrote in the 4th comment:
Votes: 0
n has nothing to do with fscanf.

n comes from skill_lookup (buf)
06 May, 2009, Davion wrote in the 5th comment:
Votes: 0
It looks like you're trying to use regex within the fscanf statement. fscanf works just like printf (though in reverse). I think what you want is to read a string (the skill name, maybe?). Try

fscanf (fp, " %s\n", buf); /* read name of skill into buf */


Might fix things.
07 May, 2009, David Haley wrote in the 6th comment:
Votes: 0
Even if fscanf is being used incorrectly, the compiler is complaining about the fact that its return value is ignored, meaning that you might miss things like EOF, failure to read, etc.
0.0/6