#include <iostream>
#include <string.h>
using namespace std;
int main() {
string str1 = "Apples are red";
string str2 = str1.substr(11, 3);
string str3 = str1.substr(0, 6);
cout << "Substring starting at position 11 and length 3 is: " << str2 <<endl;
cout << "Substring starting at position 0 and length 6 is: " << str3;
return 0;
}
Code Example |
---|
Cpp :: c++ type casting |
Cpp :: sin in c++ |
Cpp :: cpp convert vector to set |
Cpp :: use lower bound in pair vector |
Cpp :: print vector of vector c++ |
Cpp :: loop through a vector in c++ |
Cpp :: iteraate through a vector |
Cpp :: c++ length of char array |
Cpp :: how to check if a number is prime c++ |
Cpp :: c++ get full line of input |
Cpp :: cpp binary tree |
Cpp :: c++ max of array |
Cpp :: sieve of eratosthenes algorithm in c++ |
Cpp :: push_back struct c++ |
Cpp :: bitwise count total set bits |
Cpp :: C++ cin cout |
Cpp :: destructor in c++ |
Cpp :: remove decimal c++ |
Cpp :: string.begin() c++ |
Cpp :: naive pattern matching algorithm |
Cpp :: sort vector in reverse order c++ |
Cpp :: initialize vector of vector c++ |
Cpp :: c++ thread incide class |
Cpp :: cpp create lambda with recursion |
Cpp :: inline in class in C++ |
Cpp :: what is - in c++ |
Cpp :: substr in cpp |
Cpp :: priority queue in c++ |
Cpp :: iterate vector c++ |
Cpp :: list in c++ |