From 26c490f404731d053a6205719b6246502c07b449 Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Sat, 14 Jun 2014 16:46:27 +0200 Subject: init --- ccc/substr.cc | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 ccc/substr.cc (limited to 'ccc/substr.cc') diff --git a/ccc/substr.cc b/ccc/substr.cc new file mode 100644 index 0000000..9a91adc --- /dev/null +++ b/ccc/substr.cc @@ -0,0 +1,23 @@ +#include +#include + +using namespace std; + + +int main(void) +{ + // 0 12 34 56 + string s("aaax\tbx\tcxasd\tdx"); + unsigned f = 0; + for(unsigned i = 0; i < 3; i++) { + unsigned e = f; + f = s.find("\t", f+1); + cout << "e:" << e << " f:" << f << endl; + if (e !=0) cout << "'" << s.substr(e+1, f-e-1) << "'" << endl; + else cout << "'" << s.substr(0, f) << "'" << endl; + } + cout << "---" << endl; + s.erase(0, f+1); + cout << "'" << s << "'" <