Windows' std::string::find_first_of error

This is a discussion on Windows' std::string::find_first_of error within the C++ Programming forums, part of the General Programming Boards category; Hi, I've just got this peculiar problem: Code: .... std::string buffer ("tandard "); if (buffer.find_first_of("err") != std::string::npos ) { OutputDebugString ...

  1. #1
    In the Land of Diddly-Doo g4j31a5's Avatar
    Join Date
    Jul 2006
    Posts
    476

    Windows' std::string::find_first_of error

    Hi, I've just got this peculiar problem:

    Code:
    ....
    std::string buffer ("tandard ");
    if (buffer.find_first_of("err") != std::string::npos )
    {
           OutputDebugString ("Error found!");
    }
    ...
    As you can see, I'm trying to parse the string and if it has any occurence of the word "err", it would display the debug string. The funny thing is, even when the string don't have the word "err" at all like the "tandard " above, it would still call the OutputDebugString. Now why would that happen? It the STL in windows still suck?

    Thanks in advance.
    ERROR: Brain not found. Please insert a new brain!

    “Do nothing which is of no use.” - Miyamoto Musashi.

  2. #2
    In the Land of Diddly-Doo g4j31a5's Avatar
    Join Date
    Jul 2006
    Posts
    476
    Nvm. My bad. I should've used find instead of find_first_of.
    ERROR: Brain not found. Please insert a new brain!

    “Do nothing which is of no use.” - Miyamoto Musashi.

  3. #3
    The larch
    Join Date
    May 2006
    Posts
    3,573
    Exactly, find_first_of finds the first occurrence of any of the characters listed: e or r.
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  4. #4
    In the Land of Diddly-Doo g4j31a5's Avatar
    Join Date
    Jul 2006
    Posts
    476
    @anon: yeah, my mistake. 6 months of doing TorqueScript has wiped out most of my C++ I think. I even have to re-learn the concept of pointer.
    ERROR: Brain not found. Please insert a new brain!

    “Do nothing which is of no use.” - Miyamoto Musashi.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. how do you resolve this error?
    By -EquinoX- in forum C Programming
    Replies: 32
    Last Post: 11-05-2008, 03:35 PM
  3. Avoiding Global variables
    By csonx_p in forum Windows Programming
    Replies: 32
    Last Post: 05-19-2008, 12:17 AM
  4. error: template with C linkage
    By michaels-r in forum C++ Programming
    Replies: 3
    Last Post: 05-17-2006, 08:11 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 12:10 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21