From 626c2cd921e7442c20ac1be7be0b9ecb44d00c95 Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Sat, 6 Sep 2014 22:32:49 +0100 Subject: cc examples --- c,cc/reset_stringstream.cc | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 c,cc/reset_stringstream.cc (limited to 'c,cc/reset_stringstream.cc') diff --git a/c,cc/reset_stringstream.cc b/c,cc/reset_stringstream.cc new file mode 100644 index 0000000..474f014 --- /dev/null +++ b/c,cc/reset_stringstream.cc @@ -0,0 +1,25 @@ +#include +#include +#include + +using namespace std; + +int +main(void) +{ + string s("X,1"); + string t("1"); + int i; + istringstream ss(s); + if (ss >> i) { + cout << i << endl; + } else { + ss.clear(); + string buf; + while(ss.good() && getline(ss,buf,',')) + cout << buf << endl; + } + + return 0; +} + -- cgit v1.2.3