Horje
how to get a section of a string in c++ Code Example
how to get a section of a string in c++
// string::substr
#include <iostream>
#include <string>
using namespace std;

int main ()
{
  string str="We think in generalities, but we live in details.";
                             // quoting Alfred N. Whitehead
  string str2, str3;
  size_t pos;

  str2 = str.substr (12,12); // "generalities"

  pos = str.find("live");    // position of "live" in str
  str3 = str.substr (pos);   // get from "live" to the end

  cout << str2 << ' ' << str3 << endl;

  return 0;
}




Cpp

Related
decltype in c++ Code Example decltype in c++ Code Example
statement that causes a function to end in c++ Code Example statement that causes a function to end in c++ Code Example
c++ vector loop delete Code Example c++ vector loop delete Code Example
print all number between a and b in c++ Code Example print all number between a and b in c++ Code Example
iterate vector in reverse c++ Code Example iterate vector in reverse c++ Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
13