Created
July 3, 2015 04:51
-
-
Save nodakai/548eaaa9ca173e7ebf24 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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