Is space a character ?

This is a discussion on Is space a character ? within the C++ Programming forums, part of the General Programming Boards category; Is space a character ?...

  1. #1
    Registered User
    Join Date
    Jul 2008
    Posts
    91

    Is space a character ?

    Is space a character ?

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,699
    No. Also, in addition to whitespace, tabs, linefeeds, newlines, etc. are generally considered 'space'.
    Code:
    bool fun(bool value)
    {
        return std::pow(std::exp(1), std::complex<float>(0, 1) 
        * std::complex<float>(std::atan(1)*(1 << (value + 2))))
        .real() > 0;
    }

  3. #3
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,588
    Yes, a space literal (' ') is a character, or perhaps more precisely, a char literal.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  4. #4
    Registered User
    Join Date
    Jul 2008
    Posts
    91
    Are the answers different?

  5. #5
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,699
    No, Laserlight is correct. It's early, and for some reason I was thinking 'alphanumeric character'.
    Code:
    bool fun(bool value)
    {
        return std::pow(std::exp(1), std::complex<float>(0, 1) 
        * std::complex<float>(std::atan(1)*(1 << (value + 2))))
        .real() > 0;
    }

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Yes, they are two different answers. Yes, space is a character. But depending on the circumstances, it may be "ignored" by functions and applications. Other times it is very much "used" or "meaningful".

    As a part of the ascii character set, space is definitely a character, with the value 0x20 (32 decimal). Other character sets may use other values.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  7. #7
    Registered User
    Join Date
    Jul 2008
    Posts
    91
    So, space is a character

  8. #8
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by freddyvorhees View Post
    So, space is a character
    There certainly is a character in the character set that corresponds to space, yes. There are other "blank" characters, such as tab, newline, vertical tab, carriage return and possibly others.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  9. #9
    Registered User
    Join Date
    Jul 2008
    Posts
    91
    Nice. Thanks

  10. #10
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    For that matter, Unicode defines about 10 different space characters - space, n-width space, m-width space, zero-width non-joiner, non-breaking space, and more.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sequential file program
    By needhelpbad in forum C Programming
    Replies: 80
    Last Post: 06-08-2008, 01:04 PM
  2. pipe
    By smart girl in forum C Programming
    Replies: 4
    Last Post: 04-30-2006, 09:17 AM
  3. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 01:53 AM
  4. Suggest another way or how can my code be improved
    By peterchen in forum C Programming
    Replies: 6
    Last Post: 01-23-2006, 03:37 PM
  5. Problem with loop stopping at wrong time
    By Baron in forum C Programming
    Replies: 11
    Last Post: 12-14-2005, 07:35 PM

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