I try reading a text file written in this format:
p1 111 1111 pD1
p2 222 2222 pD2
p3 333 3333 pD3
but the output just keep on looping
the last line in the file after outputing 1st 2 line in the text file.
my code
is
Code:#include <stdio.h> #include <stdlib.h> #include <conio.h> #include <math.h> #include <iostream.h> #include <fstream.h> #include <iomanip> main() { char pk[BUFSIZ]; char pD[BUFSIZ]; int e; int n; ifstream b_file("c:/check.txt"); while ( b_file.eof != 0 ) { cout << "\n"; //flushall(); b_file >> pk; cout << pk; cout << "\n"; b_file >> e; cout << e; cout << "\n"; b_file >> n; cout << n; cout << "\n"; b_file >> pD; cout << pD; cout << "\n"; } b_file.close(); return(0); }
Can anyone help me on this problem.