gcc 4.4.4 c89
I have the following file which contains name, age and gender. I try to read at this age.
"Bloggs, Joe" 34 M
I can successfully open the file:
fp = fopen("input.txt", "r");
if(fp == NULL) {
fprintf(stderr, "Failed to open file [ %s ]\n", strerror(errno));
return 1;
}
And I try to read at the age of (34).
int age = 0;
int result = 0;
result = fscanf(fp, "%d", &age);
However, when I try to print the result, I always get zero by age and result.
Thanks so much for any suggestions,
source
share