Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

"new line" character

happy_84khappy_84k Member Posts: 106
hey there...

i've noticed something seemed strange to me...
if anyone just open the Notepad and type just ONE "Enter" , and if you save the .txt file and check its size, you will notice that its size is TWO bytes... but why???
i know that, in c++,u can store the new line '
' in a single byte character... but when i checked the ASCII character set, i've noticed that there isn't a single character representing the new line...
there are the LF and CR characters, but what does this characters exactly means? and what happens really in notepad??

thanks
ak

Comments

  • VilanyeVilanye Member Posts: 684
    0xD is the ascii value for carriage return.

    I believe the reason your .txt file is 2 bytes is because of the carriage return and end of file marker.

    : hey there...
    :
    : i've noticed something seemed strange to me...
    : if anyone just open the Notepad and type just ONE "Enter" , and if you save the .txt file and check its size, you will notice that its size is TWO bytes... but why???
    : i know that, in c++,u can store the new line '
    ' in a single byte character... but when i checked the ASCII character set, i've noticed that there isn't a single character representing the new line...
    : there are the LF and CR characters, but what does this characters exactly means? and what happens really in notepad??
    :
    : thanks
    : ak
    :

  • happy_84khappy_84k Member Posts: 106
    : 0xD is the ascii value for carriage return.
    :
    : I believe the reason your .txt file is 2 bytes is because of the carriage return and end of file marker.
    :

    hey man...

    but i think there is no 'end of file marker',
    try to save a new file without typing anything in it.
    its size would be Zero!!!!

    thanx
    ak

  • stoberstober Member Posts: 9,765 ✭✭✭
    The end-of-line markers depend on the operating system.

    MS-DOS/Windows: Carriage Return/Line Feed, often CR/LF, which is two characters. If the file is opened in text mode, C/C++ compilers translate '
    ' into "
    " pair before writing them out to the file, and translate "
    " to "
    " when reading them back. When the file is opened in binary mode, no translation takes place.

    *nix (Unix and Linux): end-of-line marker is "
    ", with no translation in either text or binary mode.

    MAC: end-of-line marker is "
    ". I suspece (but don't know for a fact) that "
    " is translated into "
    " when read, to maintain c/c++ standards.
  • shaolin007shaolin007 Member Posts: 1,018
    : hey there...
    :
    : i've noticed something seemed strange to me...
    : if anyone just open the Notepad and type just ONE "Enter" , and if you save the .txt file and check its size, you will notice that its size is TWO bytes... but why???
    : i know that, in c++,u can store the new line '
    ' in a single byte character... but when i checked the ASCII character set, i've noticed that there isn't a single character representing the new line...
    : there are the LF and CR characters, but what does this characters exactly means? and what happens really in notepad??
    :
    : thanks
    : ak
    :
    Mine says 3 bytes and under a hex editor it shows why.

    [code]
    31 0d 0a
    [/code]
    0d & 0a take each a byte in memory carraige return and line feed.
  • viki007viki007 Member Posts: 46
    : hey there...
    :
    : i've noticed something seemed strange to me...
    : if anyone just open the Notepad and type just ONE "Enter" , and if you save the .txt file and check its size, you will notice that its size is TWO bytes... but why???
    : i know that, in c++,u can store the new line '
    ' in a single byte character... but when i checked the ASCII character set, i've noticed that there isn't a single character representing the new line...
    : there are the LF and CR characters, but what does this characters exactly means? and what happens really in notepad??
    :
    : thanks
    : ak
    :

    once i broke "Enter" into 2 symbows and they looked like squares seperately but when i put one in front of the other they turn into an enter and that looks strange... i mean u put something if front of a symbow and it turns into an enter lol...i could actualy use them as any other symbow (copy and paste them wherever i want)

    [hr]
    by viki007

Sign In or Register to comment.