Scanning Strings till no white space is found?

This is a discussion on Scanning Strings till no white space is found? within the C++ Programming forums, part of the General Programming Boards category; Hey Guys Have tried the forums but failed to find a solution. How can i scan a string lets say ...

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    7

    Scanning Strings till no white space is found?

    Hey Guys

    Have tried the forums but failed to find a solution.

    How can i scan a string lets say " homer1 = 2+1"
    so that i am given the position as an integer of the first charector that is not a white space.

    I have tried:

    int temp = string1.find_first(!(' '));

    but even i knew that wouldnt work d'oh!

    can anyone help me out?

    Thanks in advance

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,672
    Maybe...
    Code:
    string string1( " homer1 = 2+1" );
    int iPos = string1.find_first_not_of(' ')
    Something like that I think, I've never used that string member function so I could be wrong about its usage.
    I used to be an adventurer like you... then I took an arrow to the knee.

  3. #3
    Registered User
    Join Date
    Apr 2002
    Posts
    7
    nevermind guys sorry i had never heard of the find_first_not_of()

    derrrr.

    sorry for the hassle

  4. #4
    Registered User
    Join Date
    Apr 2002
    Posts
    7
    yeh thats it mate sorry about posting the question just never searched the c libraries enough.

    cheers for the response though

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Line Counting
    By 00Sven in forum C Programming
    Replies: 26
    Last Post: 04-02-2006, 08:59 PM
  2. Going out of scope
    By nickname_changed in forum C++ Programming
    Replies: 9
    Last Post: 10-12-2003, 06:27 PM
  3. finding strings in strings
    By watshamacalit in forum C Programming
    Replies: 14
    Last Post: 01-11-2003, 12:08 AM

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