My first line is set to 4 bytes. The second is an integer between 1 and 1000. I want to code if it is not too much a constraint. I used this piece of code using the function scanf that works and meets my needs but I do not know if this is optimal.
Code:
void reading_file()
{
char *name = "foo.txt";
char value1[4];
char value2[BUFSIZ];
FILE *file;
if ((file = fopen (name, "r")) == NULL)
perror ("Impossible to open the file.");
else
{
while ( fscanf ( file, "%s %s", value1, value2 ) == 2)
printf("%s\n%s\n", value1, value2);
fclose (file);
}
}
The problem is when I try to do a comparison test between value1 and an integer, I have this error message:
Attention: Comparison between a pointer and an integer
Bookmarks