I am having trouble reading a file.
The file constists of one positive integer on a line.
ex.
1
2
3
4
5
....
And the code I wrote prints off really really weird numbers, any help?
Code:#include <stdio.h>
int main(){
FILE *fp;
int c;
char loc[] = "readThisFile.txt";
if(!(fp = fopen( loc, "r"))){
perror("fopen");
printf("Error: File could not be opened");
return 0;
}
while( (c = getc( fp ) ) != EOF ){
printf( "%d\n", c);
}
printf("\ndone\n");
getchar();
}

