In my program I'm trying to read a text file that contains integers into a 2-D char array. I believe my problem is that fgetc reads chars and not ints so when I try to print the value it shows ascii value.
The text files looks like this:
11111111111111111111111111111111
10000000000000000000000000000001
12010011111111111111111111001001
10110000000000000000000000001101
10001100111111111111111100110001
and my loadmap function looks like this:
Code:char map[24][32]; void loadMap(void) { FILE *fp; int i,j; char ch; fp = fopen("map01.txt","r"); if(!fp) { printf("Failed to load map01.txt"); getch(); exit(1); } for(i = 0; i < MAXY; i++) { for(j = 0; j <MAXX; j++) { ch = fgetc(fp); } } getch(); fclose(fp); }



LinkBack URL
About LinkBacks


