Search
 
SCRIPT & CODE EXAMPLE
 

CPP

string substr c++

s.substr(pos,len);
Comment

std::string substr

/ string::substr (pos, len)
#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" (pos, len)							
  	
  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;
}

/*
* this will be the output :--
*	"think live in details."
*/
Comment

PREVIOUS NEXT
Code Example
Cpp :: c++ concatenate strings 
Cpp :: copy constructor for vector c++ 
Cpp :: c++ pass function as argument 
Cpp :: Program to find GCD or HCF of two numbers c++ 
Cpp :: memcpy in cpp 
Cpp :: c++ check first character of string 
Cpp :: A Program to check if strings are rotations of each other or not 
Cpp :: c++ pointers 
Cpp :: long long vs long long int 
Cpp :: c++ itoa 
Cpp :: deque 
Cpp :: auto in cpp 
Cpp :: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/ 
Cpp :: online converter c++ to c 
Cpp :: C++ file . 
Cpp :: wgat is duble in c++ 
Cpp :: Code debut C++ 
Cpp :: Bit Tricks for Competitive Programming c ++ 
Cpp :: point in polygon 
Cpp :: adding two dates using necessary member function in c++ 
Cpp :: how to signify esc key in cpp 
Cpp :: strong number in c++ 
Cpp :: viewlist exaple win32 
Cpp :: multi variable assignment cpp 
Cpp :: How to execute a command and get return code stdout and stderr of command in C++ 
Cpp :: how to use run total in C++ 
Cpp :: KUNG FU HUSTLE 
Cpp :: statement that causes a function to end in c++ 
Cpp :: libraries required for gaming in c++ 
Cpp :: operator overloading prefix postfix c++ 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =