Thread: Scanning Strings till no white space is found?

  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,817
    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.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  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, 01:08 AM