When reading a txt file, how to skip the first line?
Thanks.
Just ignore what you have read in first line:
fh = fopen("filename.txt", "r" );
if( fh )
{
linecounter = 0;
while( ! feof( fh ) )
{
line = fgets( fh );
if( linecounter > 0 )
{
// process text when it is in second and subsequent lines
}
else
{
// this is entered for only very first line so by doing nothing you skip first line
}
linecounter++; // count lines
}
fclose( fh );
}
2 Likes