My program reads the last row of data from the intrusion twice. When I run the program, the last line of data is printed twice. Please, help! Here is the code
while ( !feof ( in ) ) {
}
I hope this is due to functionality feof.
I do not want to use fgetsor getline. Is there another way? Please guide me.
Thanks to everyone who answered me! I got a solution for this! I did with fgetcand unfgetcin a loop do.
Here is the code:
int ch;
ch=fgetc(fp);
do
{
ungetc(ch,fp);
ch=fgetc(fp);
} while( (ch = fgetc(fp)) != EOF && ch != '\n' );
source
share