summaryrefslogtreecommitdiff
path: root/c,cc/substr.cc
blob: 9a91adc6df6df75b56fc58e202190aaf055e95ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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;
}