diff options
| author | Patrick Simianer <p@simianer.de> | 2014-06-15 03:50:12 +0200 | 
|---|---|---|
| committer | Patrick Simianer <p@simianer.de> | 2014-06-15 03:50:12 +0200 | 
| commit | 258e1b92ebbfdebefabc120969ab87c3d8b75c3d (patch) | |
| tree | ef4ab11fe0bf9d720cea23b35711358a8465feeb /c,cc/substr.cc | |
| parent | cf3a29feb5887344b6633ead1b4b6d5657a15a4b (diff) | |
old c,cc examples
Diffstat (limited to 'c,cc/substr.cc')
| -rw-r--r-- | c,cc/substr.cc | 23 | 
1 files changed, 23 insertions, 0 deletions
| diff --git a/c,cc/substr.cc b/c,cc/substr.cc new file mode 100644 index 0000000..9a91adc --- /dev/null +++ b/c,cc/substr.cc @@ -0,0 +1,23 @@ +#include <iostream> +#include <string> + +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 << "'" <<endl; +} + | 
