K
Kevin Zhou
I have a file that contains 22 lines, each line has two float separated
by a space.
I want to store those float data into a two-dimensional array which size
I want the program to determine at run time
so i wrote the following function to count the number of lines in the
file to determine the row size for my storage array
int countline(FILE *fp)
{
int count;
count=0;
while( (c=fgetc(fp))!=EOF){
if (c == '\n')
++lcount;
}
return lcount;
}
I know that the file pointer foward one character each time fgetc is called
Is there a way to restore the position of the file pointer to the
beginning of the file
without fclose() and fopen() the file again?
by a space.
I want to store those float data into a two-dimensional array which size
I want the program to determine at run time
so i wrote the following function to count the number of lines in the
file to determine the row size for my storage array
int countline(FILE *fp)
{
int count;
count=0;
while( (c=fgetc(fp))!=EOF){
if (c == '\n')
++lcount;
}
return lcount;
}
I know that the file pointer foward one character each time fgetc is called
Is there a way to restore the position of the file pointer to the
beginning of the file
without fclose() and fopen() the file again?