Hi All,
This script below reads a text file “map.txt”, which is in the attachment.
But Interestingly it reads an extra data. Specifically, I mean that it reads the last data one more time. Why ?
#include <iostream>
#include <fstream>
using namespace std;
void readfile() {
fstream in("map.txt",ios::in);
if (in.fail()){
cout<<"there is no map.txt"<<endl;
}
int runno;
int k=0;
while(!(in.eof())) {
in>>runno;
cout<<""<<runno<<endl;
}
}
Cheers,
Ersel
map.txt (241 Bytes)