Last active
December 17, 2015 05:09
-
-
Save johnbartholomew/5555746 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
// build with: g++ -std=c++98 -Wall -ocheck test.cpp | |
#include <iostream> | |
#include <string> | |
#include <sstream> | |
int parse_int(const char *x) { | |
std::istringstream ss(x); | |
int y; | |
ss >> y; | |
return y; | |
} | |
int main(int argc, char **argv) { | |
if (argc < 2) { | |
return 1; | |
} | |
const char *one = "one"; | |
int x = parse_int(argv[1]); | |
std::ostringstream ss; | |
ss << x; | |
std::cout << "Result: " << (x == 1 ? one : ss.str()) << "\n"; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment