Skip to content

Instantly share code, notes, and snippets.

@nodakai
Created July 3, 2015 04:51
Show Gist options
  • Save nodakai/548eaaa9ca173e7ebf24 to your computer and use it in GitHub Desktop.
Save nodakai/548eaaa9ca173e7ebf24 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
using std::cout;
using std::endl;
int main(int argc, char *argv[]) {
std::ifstream ifs(argv[1]);
std::string line, a, b;
std::istringstream iss;
while (std::getline(ifs, line)) {
cout << "[" << line << "]" << endl;
iss.clear();
iss.str(line);
const bool aOk = (iss >> a);
cout << (aOk ? "GOOD" : " bad") << endl;
const bool bOk = (iss >> b);
cout << (bOk ? "GOOD" : " bad") << endl;
cout << (iss.good() ? "GOOD" : " bad") << endl;
cout << "[" << a << "]" << ", " << "[" << b << "]" << endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment