I am having problems with fscanf getting stuck in an infinite loop. {
char num;
FILE *filePtr;
if ((filePtr = fopen("filename.txt", "r")) == NULL)
{
printf("File could not be opened");
}
else
{
while (fscanf(filePtr, "%20[^ ,]", &num) != EOF)
{
displayFun(num);
}
}
return 0;
The file input that I need it to read is: 0, 1, 2, 3, 16, 17, 1234, 5678, -201, 65534, 65535, 65536, -1
For some reason the code gets stuck in a loop and the first zero and wont continue on to the other numbers.