Hirtelen kikopiztam egy txt olvasós progimból az ideillő részt, remélem segít:
//-------------------------------------------------------
//file reading, array fulfilling, finding seperator line
//-------------------------------------------------------
if ( file != NULL )
{
char line [MAX_CHARS]; //or other suitable maximum line size
for (i=0; fgets ( line, sizeof line, file ) != NULL; i++ ) // read a line
{
sprintf(lines[i], "%s", line);
//printf("%d. %s", i, lines[i]);
if (strcmp(lines[i], "\n") ==0 )
sepline=i;
}
fclose ( file );
}
else
{
perror ( filename );
return 1; // why didn't the file open?
}