d*o 发帖数: 108 | 1 【 以下文字转载自 Programming 讨论区 】
【 原文由 duo 所发表 】
Need to understand the following questions to program in C/C++:
1. Does any text file always end with a '\n'? i.e. if a text file
contains only one character, any editor will automatically add
a '\n' at the end of a file?
2. Is there a charater in a text file called 'end of file'? Use
the above example, if a text file has only one character 'a',
how many characters for this file? i.e. is it 'a' + '\n'?
or is it 'a' + '\n' + '\eof'?
Thanks for all help! | e***o 发帖数: 14 | 2
no ( unless you hit the enter key
at least not in vi and emacs
EOF (end of file) is not a character.
So if you only type a in a new file, the there is only an a in this
file and nothing else.
【在 d*o 的大作中提到】 : 【 以下文字转载自 Programming 讨论区 】 : 【 原文由 duo 所发表 】 : Need to understand the following questions to program in C/C++: : 1. Does any text file always end with a '\n'? i.e. if a text file : contains only one character, any editor will automatically add : a '\n' at the end of a file? : 2. Is there a charater in a text file called 'end of file'? Use : the above example, if a text file has only one character 'a', : how many characters for this file? i.e. is it 'a' + '\n'? : or is it 'a' + '\n' + '\eof'?
|
|