关于fputs的问题() [英] A question about fputs()

查看:79
本文介绍了关于fputs的问题()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么没有fputs()在将空终止字符串

写入流时写入空字节?我没有看到这背后的原因。

Chad

Why doesn''t fputs() write the null byte when the null-terminted string
is written to a stream? I don''t see the reasoning behind this.

Chad

推荐答案

Chad说:
Chad said:

为什么当空终止字符串

被写入流时,fputs()是否写入空字节?我没有看到这背后的原因。
Why doesn''t fputs() write the null byte when the null-terminted string
is written to a stream? I don''t see the reasoning behind this.



也许您可以解释为什么您认为像fputs这样的面向文本的函数
应该关注非文本导向的值,例如作为一个空字节?

我没看到背后的原因/那个/。


-

Richard Heathfield < http://www.cpax.org.uk>

电子邮件:-http:// www。 + rjh @

谷歌用户:< http://www.cpax.org.uk/prg/writings/googly.php>

Usenet是一个奇怪的放置" - dmr 1999年7月29日

Perhaps you could explain why you think a text-oriented function like fputs
should concern itself with a non-text-oriented value such as a null byte?
I don''t see the reasoning behind /that/.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999


6月22日上午8:58,Richard Heathfield< r ... @ see.sig.invalidwrote:
On Jun 22, 8:58 am, Richard Heathfield <r...@see.sig.invalidwrote:

Chad说:
Chad said:

为什么没有fputs()在空终止字符串

写入流?我没有看到这背后的原因。
Why doesn''t fputs() write the null byte when the null-terminted string
is written to a stream? I don''t see the reasoning behind this.



也许您可以解释为什么您认为像fputs这样的面向文本的函数
应该关注非文本导向的值,例如作为一个空字节?

我没有看到背后的原因/那个/。


Perhaps you could explain why you think a text-oriented function like fputs
should concern itself with a non-text-oriented value such as a null byte?
I don''t see the reasoning behind /that/.



让我们说我有一个字符串如下


"这是一个字符串\ n"


如果puts删除,这不会产生未定义的行为'\ n''?

Let''s say I have a string like the following

"This is a string\n"

Wouldn''t this create undefined behavior if puts removes ''\n''?


Chad说:
Chad said:

6月22日上午8:58, Richard Heathfield< r ... @ see.sig.invalidwrote:
On Jun 22, 8:58 am, Richard Heathfield <r...@see.sig.invalidwrote:

> Chad说:
>Chad said:

为什么当空终止字符串

被写入流时,fputs()是否写入空字节?我没有看到这背后的原因。
Why doesn''t fputs() write the null byte when the null-terminted string
is written to a stream? I don''t see the reasoning behind this.


或许你可以解释为什么你认为像文件导向的函数像
fputs应该关注非文本导向的值,例如
null字节?我没有看到背后的原因/那个/。


Perhaps you could explain why you think a text-oriented function like
fputs should concern itself with a non-text-oriented value such as a
null byte? I don''t see the reasoning behind /that/.



让我们说我有一个像下面这样的字符串


"这是一个字符串\ n"


如果puts删除''\ n'',这不会产生未定义的行为吗?


Let''s say I have a string like the following

"This is a string\n"

Wouldn''t this create undefined behavior if puts removes ''\n''?



我可以更进一步,并说它会向后打印

如果将打印的东西向后推出。但是看跌期权并没有这样做 - 而且它还没有删除新行。
也没有删除换行符。文本是一种面向行的格式,并且新行定义了一行

(只要换行符出现在每行

行的末尾)。 puts函数是一个面向文本的函数,如果它删除了换行符,它确实是一个非常奇怪的鸟。我没有看到你想要赚的钱。如果你试图在null

字节和换行符之间进行比较,它就不起作用 - 换行符是

文本流的基本部分,而null字节是没有。


-

Richard Heathfield< http://www.cpax.org.uk>

电子邮件: -http:// WWW。 + rjh @

谷歌用户:< http://www.cpax.org.uk/prg/writings/googly.php>

Usenet是一个奇怪的放置" - dmr 1999年7月29日

I can go further than that, and say that it would be printed out backwards
if puts printed stuff out backwards. But puts doesn''t do that - and it
doesn''t remove newlines either. Text is a line-oriented format, and a line
is defined by newlines (insofar as a newline appears at the end of every
line). The puts function, which is a text-oriented function, would be a
very strange bird indeed if it removed newlines. I don''t see the point you
are trying to make. If you are trying to draw a comparison between null
bytes and newlines, it doesn''t work - newlines are a fundamental part of
text streams, whereas null bytes are not.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999


这篇关于关于fputs的问题()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆