So I'm currently trying to read a input file character by character and I'm trying to see when a new line occurs. I get all the characters fine, but instead of a '\n' for a new line I get 'á' or -97 if I cast it to an int. Here's my code and I'm using VS 2015.
int main(void) {
FILE *fp;
fp = open_input_file();
if (fp != 0) {
char ch = read_character(fp);
int d = (int)ch;
while (ch != EOF) {
printf("%d\n", d);
ch = read_character(fp);
d = (int)ch;
}
}
getch();
return 0;
}
char read_character(FILE *infile) {
int c;
c = getc(infile);
return (char) c;
}