Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

take pieces of a string in c++

#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;
}
Source by www.tutorialspoint.com #
 
PREVIOUS NEXT
Tagged: #pieces #string
ADD COMMENT
Topic
Name
7+5 =