summaryrefslogtreecommitdiff
path: root/c,cc/stringstream.cc
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2014-06-15 03:50:12 +0200
committerPatrick Simianer <p@simianer.de>2014-06-15 03:50:12 +0200
commit258e1b92ebbfdebefabc120969ab87c3d8b75c3d (patch)
treeef4ab11fe0bf9d720cea23b35711358a8465feeb /c,cc/stringstream.cc
parentcf3a29feb5887344b6633ead1b4b6d5657a15a4b (diff)
old c,cc examples
Diffstat (limited to 'c,cc/stringstream.cc')
-rw-r--r--c,cc/stringstream.cc26
1 files changed, 26 insertions, 0 deletions
diff --git a/c,cc/stringstream.cc b/c,cc/stringstream.cc
new file mode 100644
index 0000000..3d68db3
--- /dev/null
+++ b/c,cc/stringstream.cc
@@ -0,0 +1,26 @@
+#include <iostream>
+#include <string>
+#include <sstream>
+#include <vector>
+#include <stdio.h>
+#include <iomanip>
+
+using namespace std;
+
+
+int main(void) {
+ string s = "1 2 3 4";
+ int i;
+ vector<int> j;
+ stringstream ss(s);
+ while (ss >> i) {
+ j.push_back(i);
+ cout << i << endl;
+ }
+
+ printf("%4d %4d %4d %4d\n", j[0], j[1], j[2], j[3]);
+
+ cout.width(100);
+ cout << setw(100) << j.size() << endl;
+}
+