#include #include #include // This buggy program attempts to read strings form a text file. // Unfortunately, fscanf stops after the first space is encountered. // So, this program actually reads words and not strings. // The sample next program fixes that. int main() { FILE* fp; int a, b; if( (fp = fopen("strings.txt", "r")) == NULL) { printf("File not found!\n"); } else { int result; char STRING[1024]; while( (result = fscanf(fp, "%s", STRING)) != EOF) { printf("[%s] \t\t [result = %2d]\n", STRING, result); } fclose(fp); } system("pause"); }