Thread: syntax question

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    133

    syntax question

    hey guys I was just wondering what the following is called:

    '/0'

    Thanks.

  2. #2
    Registered User
    Join Date
    Apr 2006
    Posts
    3
    It's an escape sequence. That particular one represents the null character.

  3. #3
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    Actually, '\0' is the escape sequence that represents the null character.

    '/0' as the topic implies is a syntax error. Some compilers may just give a warning as a multi-character character constant.
    Sent from my iPadŽ

  4. #4
    Registered User
    Join Date
    Oct 2005
    Posts
    133
    Is it also known as a line terminator?

    Thanks.

  5. #5
    Registered User
    Join Date
    Apr 2006
    Posts
    5
    Quote Originally Posted by 182
    Is it also known as a line terminator?

    Thanks.
    A line terminator is \n

    Thanks,
    Logan

  6. #6
    Registered User Aran's Avatar
    Join Date
    Aug 2001
    Posts
    1,301
    \n is a line feed and a carriage return in one escape sequence. (Line feed moves the cursor down one, carriage return moves the cursor to the beginning of the line.)
    \0 is a null character.
    /0 is a divide by zero error.

  7. #7
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    '\0' is also known as the null-terminator, since in C it is used to mark the end of a string stored in a character array. Since in most cases you cannot determine the size of an array without saving that information (and even if you could, there's no guarantee that the string inside the array uses the whole thing), they use a special character to mark the end of the string. That character is '\0'.

    Another way to handle strings is to save the size of the string along with the array data, which is how it is done in C++ string classes.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Syntax question: &(++x)
    By yoshiznit123 in forum C Programming
    Replies: 8
    Last Post: 06-02-2006, 10:40 PM
  2. using c++ in c code
    By hannibar in forum C Programming
    Replies: 17
    Last Post: 10-28-2005, 09:09 PM
  3. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  4. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 08:57 AM
  5. pointer to array of objects of struct
    By undisputed007 in forum C++ Programming
    Replies: 12
    Last Post: 03-02-2004, 04:49 AM