What is 0xD??

This is a discussion on What is 0xD?? within the C++ Programming forums, part of the General Programming Boards category; Yes yes, it's 13 in hexadecimal. But first, let me tell you my story I was trying to make a ...

  1. #1
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879

    What is 0xD??

    Yes yes, it's 13 in hexadecimal. But first, let me tell you my story I was trying to make a high-scores thing, but in order to do so, I'd have to store the scores in a file. The thing is, if the file was created in Notepad, then at the end of each line there would be a newline constant ('\n'), like there should be. Then I ran my prog and got a high score, and it stored it in the file... when I reopened the file in Notepad, it looked fine but when I tried checking the highscores in my prog, it would have extra newlines at the end of each line. Puzzled, I took a look back in Notepad.... it still looked fine. Finally, I deleted a couple characters, and all of a sudden the whole thing squished into 3 lines. Puzzled, I re-made the file and got a highscore again. This time I didn't touch the file with notepad, but opened it with a hex-editor.. guess what I found? At the end of each line, there were 3 characters: 0xD, 0xD, and 0xA. Then I opened Notepad and re-did the file again, and checked it in the hex-editor again... guess what? Only one 0xD this time. So I edited my program to delete the extra 0xD, and the thing worked. So my question is, what is '0xD', and why did it screw the thing up so badly??
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

  2. #2
    Evil Member
    Join Date
    Jan 2002
    Posts
    638
    Well...


    Its kinda a tricky matter, because in ASCII mode (the default mode for opening files) line breaks are represented by a CR/LF pair. CR (carriage return) being 0xD, and LF (Line finish, aka newline) being 0xA.

    If this is a problem, try opening the file in binary mode (I think you just add ios:bin to the initializer for the stream.) That should make the CR's go away (I think)

  3. #3
    Carnivore ('-'v) Hunter2's Avatar
    Join Date
    May 2002
    Posts
    2,879
    Ok, thanks
    Just Google It. √

    (\ /)
    ( . .)
    c(")(") This is bunny. Copy and paste bunny into your signature to help him gain world domination.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Where to get the value of 0xd?
    By neo_phyte in forum C Programming
    Replies: 6
    Last Post: 08-25-2006, 03:22 AM

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