What is (char)13?

This is a discussion on What is (char)13? within the C++ Programming forums, part of the General Programming Boards category; I am working with my telnet echo program, and when i try to print it to cout, the quotes were ...

  1. #1
    Rebooted Inquirer's Avatar
    Join Date
    Apr 2002
    Posts
    281

    What is (char)13?

    I am working with my telnet echo program, and when i try to print it to cout, the quotes were put at the beginning of the line. I have traced this odd activity back to the mysterious (char)13.

    does anyone have any clue what this is?

    ~Inquirer

    P.S. i tried entering this character into ttelnet while they werew connected, and the program terminated. I don't know if this is because it evaluates "ch == '\n'" true, or if it is End Of Stream or something like that. Any help would be appreciated.
    Compilers:
    GCC on Red Hat 8.1 (Primary)
    GCC on Mac OS X 10.2.4 (Secondary)

    Others:
    MinGW on XP

  2. #2
    Registered User
    Join Date
    Jan 2002
    Posts
    559
    It's the ascii value for either carriage return or line feed, I forget which. Carriage return puts you back at column 1 and line feed puts you on the next line. char(10) is the ascii value for whichever of those values char(13) isn't.
    Truth is a malleable commodity - Dick Cheney

  3. #3
    Rebooted Inquirer's Avatar
    Join Date
    Apr 2002
    Posts
    281
    aaaaaaaah. Thanks. (char)13 must be carriage return.
    Compilers:
    GCC on Red Hat 8.1 (Primary)
    GCC on Mac OS X 10.2.4 (Secondary)

    Others:
    MinGW on XP

  4. #4
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  5. #5
    Just a Member ammar's Avatar
    Join Date
    Jun 2002
    Posts
    953
    10 is the line feed and 13 is the carriage return.

    But what is '\n'?

  6. #6
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Originally posted by ammar
    But what is '\n'?
    New-line. It is implementation-defined.
    In DOS and Windows it is two characters: char(13) and char(12)
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  7. #7
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Originally posted by Sang-drax
    New-line. It is implementation-defined.
    In DOS and Windows it is two characters: char(13) and char(12)
    Don't you mean 13 and 10?
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  8. #8
    Just a Member ammar's Avatar
    Join Date
    Jun 2002
    Posts
    953
    char(12) is a new page.
    So i think it should be char(13) and char(10)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Writing "Enter" character to a txt file
    By Hankyaku in forum C++ Programming
    Replies: 2
    Last Post: 04-08-2003, 11:06 AM

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