How can I take out a specific combination of word form a string?

Suppose I have to take "100" from the string "1001", whats the process to do it?
Last edited on
string a = "1001";
a = a.substr(3); // "1"

Or if you want a to only contain the 100
string a = "1001";
a = a.substr(0, 3); // "100"
Last edited on
Bro the point is the user will input a string like 1010101011000... I have to find out if there is 100 in the string.
std::string::find() to locate "100" http://www.cplusplus.com/reference/string/string/find/

and std::string::erase() to erase it http://www.cplusplus.com/reference/string/string/erase/
I am really sorry.. Actually I am a beginner. so i am not sure what to with this function, Like I have no space in my string but I have to see from that string if I get any combination like "0100" or "100".. can u please explain.. Thanks a lot for your help :)
Bro I got :D thanks man!
the substr is like a "perl" script
Topic archived. No new replies allowed.