do we always surround escape sequences such as \n and \t by quotation marks?

This is a discussion on do we always surround escape sequences such as \n and \t by quotation marks? within the C++ Programming forums, part of the General Programming Boards category; Hi Do we always surround escape sequences such as \n and \t by quotation marks? I think this is the ...

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    254

    do we always surround escape sequences such as \n and \t by quotation marks?

    Hi

    Do we always surround escape sequences such as \n and \t by quotation marks? I think this is the case. But I'm almost sure that I've seen \n being used without any quotation marks. Could you please confirm it? Thank you.
    I'm an outright beginner. Using Win XP Pro and Code::Blocks. Be nice to me, please.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    23,817
    Perhaps you saw them embedded in a string literal and did not notice the string literal's double quote delimiters.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Mar 2011
    Posts
    254
    Quote Originally Posted by laserlight View Post
    Perhaps you saw them embedded in a string literal and did not notice the string literal's double quote delimiters.
    Hi laserlight

    That means you are of the opinion that escape sequences are always to be embedded within the quotation marks. But I'm almost sure I have seen the usage of \n without the quotes. I will let you know if I found that usage.
    I'm an outright beginner. Using Win XP Pro and Code::Blocks. Be nice to me, please.

  4. #4
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,949
    An ASCII escape sequence is just a character.

    A character literal, within C++, has the form '!' where the exclamation marks a character.

    A string literal, within C++, has the form "!" where the exclamation marks a sequence of characters.

    It isn't an opinion. It is what is.

    Soma

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Searching a text file for double quotation marks "
    By willie in forum C Programming
    Replies: 4
    Last Post: 11-23-2008, 01:00 PM
  2. quotation marks
    By AmazingRando in forum C Programming
    Replies: 3
    Last Post: 02-02-2005, 03:12 PM
  3. Escape sequences in VC++
    By emilyh in forum Windows Programming
    Replies: 7
    Last Post: 09-26-2001, 07:02 AM
  4. Escape Sequences
    By Me-Again-Again in forum C Programming
    Replies: 3
    Last Post: 09-05-2001, 06:24 AM
  5. quotation marks
    By bart in forum C++ Programming
    Replies: 1
    Last Post: 09-02-2001, 01:15 PM

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