I am working in C and have a text file that is 617kb that I am trying to read with fgetc
. For some reason fgetc
is starting randomly within the file. I have tried moving the file pointer to get beginning with fseek
with no success. I can get fgetc
work to fine with smaller files. Any help is appreciated.
Sample input is 25,000 lines of data similar to:
Product
23 660
2366 3
237 09
2 3730
23734
23 773
241 46
Source:
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void print(FILE *category){
int ch = 'a';
while ((ch = fgetc(category)) != EOF){
printf("%c", ch);
}
getchar();
}
int main(void){
FILE *category = fopen("myFile", "r");
if (category == NULL){
puts("category file not found");
}
else{
print(category);
fclose(category);
return 0;
}
}