Redian新闻
>
[转载] Hidden character in a file
avatar
[转载] Hidden character in a file# Unix - 噫吁兮,危乎高哉
d*o
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!
avatar
e*o
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'?

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。