Thread: string

  1. #1
    Unregistered
    Guest

    string

    hi,
    how do you check to see if there is a white space b/t 2 characters? thanks in advance.

  2. #2
    Search for a ' ' in the string.

    I could be wrong though. More times than not, I'm usually worng the first time.
    DrakkenKorin

    Get off my Intarweb!!!!

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You're correct, except that more than just 'space' are considered 'white space'. Use something like:
    Code:
    for( x=0; string[x]; x++ )
        if( isspace( string[x] ) )
            printf("witespace at %d, ascii value of %d.", x, string[x] );
    EDIT: Edited to provide a link to 'isspace'.
    NOTE: There are numerous 'is' functions in ctype.h.

    Quzah.
    Last edited by quzah; 12-10-2001 at 04:13 PM.
    Hope is the first step on the road to disappointment.

  4. #4
    Unregistered
    Guest
    thanks, but i need to ignore white spaces in front and at the end of the string. i just need to check for spaces in between 2 valid characters.
    thanks.

  5. #5
    quzah:

    In your code, you use -- isspace(string[x])

    Is this a user defined function, or is in one of the header/library files?

    Thanx
    DrakkenKorin

    Get off my Intarweb!!!!

  6. #6
    Code Warrior
    Join Date
    Nov 2001
    Posts
    669
    DrakkenKorin:

    You can find command "isspace(string[x])" in "ctype.h" library.
    Current projects:
    1) User Interface Development Kit (C++)
    2) HTML SDK (C++)
    3) Classes (C++)
    4) INI Editor (Delphi)

  7. #7
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Homework?

    Use isspace or the ' ' literal in your search and choose whether or not to copy it to a temp variable. Re-copy, return.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  8. #8
    Thanx Gape.

    Gonna have to play with that one.
    DrakkenKorin

    Get off my Intarweb!!!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. compare structures
    By lazyme in forum C++ Programming
    Replies: 15
    Last Post: 05-28-2009, 02:40 AM
  2. OOP Question DB Access Wrapper Classes
    By digioz in forum C# Programming
    Replies: 2
    Last Post: 09-07-2008, 04:30 PM
  3. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 11:03 PM
  4. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 03:23 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 06:49 PM