Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

copying a substring from a string given end index in string

Tags:

c++

How can I copy a substring from a given string with start and end index or giving the start index and length of the string are given.

like image 394
boom Avatar asked May 09 '10 05:05

boom


1 Answers

std::string thesub = thestring.substr(start, length);

or

std::string thesub = thestring.substr(start, end-start+1);

assuming you want the endth character to be included in the substring.

like image 108
Alex Martelli Avatar answered Oct 05 '22 21:10

Alex Martelli