Hi, I was wondering if anyone could point me out the problem of the programme below. It can not read the data file it was supposed to read. When I run the programme, the output is just "Line:". I am kind of beginner for C++ so there is a chance that I might be making a very stupid mistake. Anyway, here is the code:
Code:#include <iostream> #include <fstream> #include <string> using namespace std; void Parse(string); int main() { fstream InFile("WindStation00.data", ios::in); string Line; while(!InFile.eof()) { InFile >> Line; cout << "LINE: " << Line << endl; Parse(Line); } InFile.close(); system("pause"); } void Parse(string Line) { string ID, Date, Hour; double Speed; int Direction; cout << "\t" << strtok((char*)Line.c_str(), ":") << endl; cout << "\t" << strtok(0, ":") << endl; cout << "\t" << strtok(0, ":") << endl; cout << "\t" << strtok(0, ":") << endl; cout << "\t" << strtok(0, ":") << endl; }



3Likes
LinkBack URL
About LinkBacks



I used to be an adventurer like you... then I took an arrow to the knee.