Re: [Dev-C++] searching characters in a string newbie
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: <or...@vp...> - 2005-01-08 01:13:22
|
Patel, Nilesh M wrote: > This maybe a easy one. But I have a string containing '|'. > I need to write a little code where it search for '|' and returns > whatever string is between the first '|' and the 2nd '|'.=20 >=20 > Myabe this might be more clear. >=20 > cat|dog|mouse|house. >=20 > the cat, dog, mouse and house and not predefined. >=20 > so i need a way where i can search for '|' and another '|' and return d= og.=20 >=20 > i tried doing a method using find_first_of method, but did not turn out= correctly.=20 >=20 > any suggestions? Use string::find() to find both the first, and the second "|", then use=20 string::substr() to get what's in between. A very good reference about C++ strings can be found here: http://www.cppreference.com/cppstring.html -- Greetings, Bal=E1zs |