Difficulties appear in my homework again. I am writing a program to count the number of whitespace characters in a text file. I use "isspace" to count it. The content in the text file is "1 1 1", but the counter still 0, what's wrong of the codes?
#include "stdafx.h"
#include "ctype.h"
int _tmain(int argc, _TCHAR* argv[])
{
FILE* input;
char x;
int space = 0;
input = fopen("123.txt", "r");
while ((fscanf(input, " %c", &x)) == 1)
{
if (isspace(x))
space++;
}
printf("space : %d\n", space);
return 0;
}