The file (testfile.txt):
Code: Select all
test test test
Code: Select all
if(file.is_open()) {
string str;
while(!file.eof()) {
char c;
file.get(c);
cout << c;
if(c != ' ' && c != '\n' && c != '\r')
str += c;
else {
Token token(str);
tokens.push_back(token);
str = "";
}
}
if(str.size() > 0) {
Token token(str);
tokens.push_back(token);
}
}
test test testt