Search
 
SCRIPT & CODE EXAMPLE
 

CPP

get part of string c++

// string::substr
#include <iostream>
#include <string>

int main ()
{
  std::string str="We think in generalities, but we live in details."; // (quoting Alfred N. Whitehead)
  std::string str2 = str.substr (3,5);     // "think"
  std::size_t pos = str.find("live");      // position of "live" in str
  std::string str3 = str.substr (pos);     // get from "live" to the end
  std::cout << str2 << ' ' << str3 << '
';
  return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: set precision with fixed c++ 
Cpp :: map in c++ sorted descending order 
Cpp :: c++ construnctor 
Cpp :: string vector c++ 
Cpp :: how to make calculaor in c++ 
Cpp :: data types ranges c++ 
Cpp :: C++ Volume of a Sphere 
Cpp :: how to get size of char array in c++ 
Cpp :: max of a vector c++ 
Cpp :: flags for g++ compiler 
Cpp :: c++ typeid 
Cpp :: find max value in array c++ 
Cpp :: c++ sieve of eratosthenes 
Cpp :: string to decimal c++ strtol 
Cpp :: cpp std list example 
Cpp :: restting a queue stl 
Cpp :: c++ reference 
Cpp :: combine two vectors c++ 
Cpp :: upcasting in c++ 
Cpp :: set clear c++ 
Cpp :: convert unsigned long to string c++ 
Cpp :: c++ array size 
Cpp :: c++ remove element from vector 
Cpp :: reverse level order traversal 
Cpp :: bubblesort c++ 
Cpp :: json::iterator c++ 
Cpp :: float to int c++ 
Cpp :: what is g++ and gcc 
Cpp :: sort c++ 
Cpp :: getline 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =