Thread: Escape characters

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    84

    Escape characters

    I have just been reading about escape characters and as well
    as the obvious

    '\n' newline
    '\t' tab

    kinda thing it also included

    '\?'

    What is the use of this escape character when '?' seems to work perfectly well?

    Anyone?

    Thanks.

  2. #2
    Are you sure that ? is not to be replaced with something (from a list further down the page or something)?

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    84
    Code:
    #include<iostream>
    using namespace std;
    
    int main(void)
    {
    	cout << "Hello?" << endl; 
    	cout << "Hello\?" << endl;
    
    	return(0);
    }
    When i run the above program both lines are identical.
    I use MSVC++ if that makes any difference!

  4. #4
    Registered User
    Join Date
    Apr 2002
    Posts
    362
    The ASCII name for a question mark is simply the question mark character (?).

    The C++ name for a question mark is preceded by the backslash character.

    In this particular instance, there is little difference, but consider '\a' - alert - (C++). The ASCII name is 'BEL'.

    Of course, there are others. In C++, '\n' is the newline character. In ASCII, it's NL or LF.

    You just latched onto one that doesn't appear a lot different.

    No doubt, the issue runs into "portability" and, I must confess, I'm ill-prepared to offer much to you in that area.

    Perhaps others can.

    "When the only tool you own is a hammer, every problem begins to resemble a nail." Abraham Maslow

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A development process
    By Noir in forum C Programming
    Replies: 37
    Last Post: 07-10-2011, 10:39 PM
  2. Replies: 10
    Last Post: 07-10-2008, 03:45 PM
  3. How do you check how many characters a user has entered?
    By engstudent363 in forum C Programming
    Replies: 5
    Last Post: 04-08-2008, 06:05 AM
  4. help with text input
    By Alphawaves in forum C Programming
    Replies: 8
    Last Post: 04-08-2007, 04:54 PM
  5. stringstream with escape characters
    By Queue in forum C++ Programming
    Replies: 1
    Last Post: 11-22-2006, 06:24 PM