Finding part of the string followed by space

Hello,
How can I actually find part of the string lets say:
string abc ("1000 1111 11")

I want to find number 11 and issue is that it will find number 11 in number 1111 and thats not what I want thats why my number has to be followed by a space or if its at the end of the string as seen up.

Summarized: I want to find exact number not number in a number.

Anyone knows a solution to this? Thanks in advance.

UPDATE: Forgot to mention, to be returned as bool not position int.
You can break your string up into individual words by converting it into a std::istream.
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <sstream>

// ...

std::string str = "1000 1111 11";

std::istringstream iss(str);

std::string word;
while(iss >> word)
{
    // Examine each word here
}
Just because this project would make for good practice with using the STL Algorythms I recommend this: http://www.cplusplus.com/reference/algorithm/equal/

EDIT: But, without compiling and running, it looks like Galik is correct to. Nobody ever said there is only one way to do things in C++.
Last edited on
Topic archived. No new replies allowed.