I want to read multiple integers into a 1 dimensional array from different files but how can I track at what position "i" stopped so I can continue saving from the position where "i" stopped? I am not allowed to have multiple files at a time opened and that's irritating me. I have read the rows and columns size of each file already and saved it.
len = rows * cols;
for(int i=0;i<len;i++) {
fscanf(fp, "%d", &array[i]);
}
is a for loop the loop I have to go with or would an other loop be better? Maybe it's possible to use a pointer to track down the position where the loop stopped, something like this?
int i = 0;
char c;
do{
fscanf(fp, "%d", &array[i]);
i++;
*cnt = i;
}while((c=fgetc(fp)) != EOF);
but how do I set "i" to cnt when I call the function a second time?