i have something like this:
first i count '\n' in a file to know how large the array should be , so i use getc. then i want to put those lines in array with fgets.Code:k = 0; while ( (c = getc(fp)) != EOF ) { if ( c == '\n') k++; } char dat[k][200]; printf("\n%d\n",k); i = 0; while( fgets(dat[i++],sizeof dat[j],fp) != NULL )
The problem is that fgets doesnt read the lines already read by getc and array is not filled with correct values.