fgets()等价? [英] fgets() equivalent?

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

问题描述

HSfgets()是C文件I / O的标准配置。

HS>

HST这个唯一的问题你也需要注意,是RAW

HS(二进制)vs COOK模式。它将涉及MS-DOS(< CRL>< LR>)与/或
HSUnix(< LF>)的EOL(结束/ b $ b HSof行)定义。取决于您的应用程序

HSmay或可能不属于。


TR这是一个方便的定义,但它是不正确的。 [...]

TR在Unix中的原始与熟的区别非常不同

TR来自MS-DOS中的二进制与文本区别。 [...]


实际上,二进制/文本二分法来自C语言。

操作系统本身具有并且没有这样的区别。 (为了
操作系统本身,文件只是八位字节流。有

没有行,没有换行序列,也没有EOF标记字符。)它

就是针对PC / MS / DR的C语言实现的情况 -
DOS使用文本文件的-CR + LF-or-LF换行约定

(尽管他们不要求这样做)和C语言

实现目标Unices和Linux使用LF换行符

约定文本文件(并且需要通过POSIX

标准来实现,它定义了对C实现的其他限制。

HSfgets() is standard in C file I/O.
HS>
HSThe only issue you need to pay attention too, is RAW
HS(binary) vs COOK mode. It will relate the EOL (end
HSof line) definitions of MS-DOS (<CRL><LR>) vs
HSUnix (<LF>). Depending on your application that
HSmay or may no pertain.

TRThis is a handy definition, but it is NOT CORRECT. [...]
TRThe raw vs cooked distinction in Unix is VERY different
TRfrom the binary vs text distinction in MS-DOS. [...]

Actually, the binary/text dichotomy comes from the C language. The
operating systems themselves have and make no such distinction. (To
the operating systems themselves, files are just octet streams. There
are no lines, no newline sequences, and no EOF marker characters.) It
is simply the case that C language implementations targetting PC/MS/DR-
DOS use the either-CR+LF-or-LF newline convention for text files
(although they are not required to do so), and C language
implementations targetting Unices and Linux use the LF newline
convention for text files (and are required to do so by the POSIX
standard, which defines additional restrictions on C implementations).

推荐答案

J de Boyne Pollard写道:
J de Boyne Pollard wrote:

HSfgets()是C文件I / O的标准配置。

HS>

仅限问题你需要注意,是RAW

HS(二进制)vs COOK模式。它将涉及MS-DOS(< CRL>< LR>)与/或
HSUnix(< LF>)的EOL(结束/ b $ b HSof行)定义。取决于您的应用程序

HSmay或可能不属于。


TR这是一个方便的定义,但它是不正确的。 [...]

TR在Unix中的原始与熟的区别非常不同

TR来自MS-DOS中的二进制与文本区别。 [...]


实际上,二进制/文本二分法来自C语言。

操作系统本身具有并且没有这样的区别。 (对于操作系统本身来说,
,文件只是八位字节流。

没有行,没有换行序列,也没有EOF标记字符。)
HSfgets() is standard in C file I/O.
HS>
HSThe only issue you need to pay attention too, is RAW
HS(binary) vs COOK mode. It will relate the EOL (end
HSof line) definitions of MS-DOS (<CRL><LR>) vs
HSUnix (<LF>). Depending on your application that
HSmay or may no pertain.

TRThis is a handy definition, but it is NOT CORRECT. [...]
TRThe raw vs cooked distinction in Unix is VERY different
TRfrom the binary vs text distinction in MS-DOS. [...]

Actually, the binary/text dichotomy comes from the C language. The
operating systems themselves have and make no such distinction. (To
the operating systems themselves, files are just octet streams. There
are no lines, no newline sequences, and no EOF marker characters.)



不是所有操作系统的情况。许多系统如CP / M和一些

大型机都有一个面向记录的文件系统,其中文件表示为一系列记录。 CP / M还有一个文件结尾

标记。此外,非8位字节系统可能无法将文件视为八位字节

流。


< snip>

Not the case with all operating systems. Many systems like CP/M and some
mainframes have a record oriented file system, where the file is
represented as a sequence of records. CP/M also had a end-of-file
marker. Also non 8-bit byte systems may not view files as an octet
stream.

<snip>


TR这是一个方便的定义,但它不是正确的。 [...]

TR在Unix中的原始与熟的区别非常不同

TR来自MS-DOS中的二进制与文本区别。 [...]


JdeBPA实际上,二进制/文本二分法来自C

JdeBPlanguage。操作系统本身有
JdeBPand没有这样的区别。 (对于操作

JdeBPsystems本身,文件只是八位字节流。

JdeBPThere没有行,没有换行序列,也没有

JdeBPEOF标记字符。)


s不适用于所有操作系统。 [...]


M. Roberts并未谈及所有操作系统。操作

系统,xe正在谈论xe提到的名称。
TRThis is a handy definition, but it is NOT CORRECT. [...]
TRThe raw vs cooked distinction in Unix is VERY different
TRfrom the binary vs text distinction in MS-DOS. [...]

JdeBPActually, the binary/text dichotomy comes from the C
JdeBPlanguage. The operating systems themselves have
JdeBPand make no such distinction. (To the operating
JdeBPsystems themselves, files are just octet streams.
JdeBPThere are no lines, no newline sequences, and no
JdeBPEOF marker characters.)

sNot the case with all operating systems. [...]

M. Roberts wasn''t talking about all operating systems. The operating
systems that xe was talking about xe mentioned by name.


J de Boyne Pollard< j。****** ********@tesco.netwrote:
J de Boyne Pollard <j.**************@tesco.netwrote:

>
实际上,二进制/文本二分法来自C语言。
操作系统本身具有并且没有这样的区别。 (对于操作系统本身,文件只是八位字节流。没有行,没有换行序列,也没有EOF标记字符。)
>
Actually, the binary/text dichotomy comes from the C language. The
operating systems themselves have and make no such distinction. (To
the operating systems themselves, files are just octet streams. There
are no lines, no newline sequences, and no EOF marker characters.)



对不起,但你错了。显然,你从来没有因为使用复制而尝试使用

。没有/ b的命令在早期版本的MS-DOS上,一个

文件恰好包含一个嵌入式Ctrl-Z(文本模式

文件结束字符)。反过来,它继承了CP / M的行为。


C运行时库必须添加文本/二进制区别,因为CP / M

和MS-DOS将它嵌入到它们的文件系统机制中。在为这些操作系统构建实现之前,这个概念肯定不是C运行时的一部分。

-

Tim Roberts, ti**@probo.com

Providenza& Boekelheide,Inc。

I''m sorry, but you are incorrect. Apparently, you never got burned trying
to use the "copy" command without "/b" in the early versions of MS-DOS on a
file that happened to contain an embedded Ctrl-Z (the text-mode "end of
file" character). It, in turn, inherited that behavior from CP/M.

The C run-time library had to ADD the text/binary distinction because CP/M
and MS-DOS embedded it in their file system mechanisms. That concept was
certainly not part of the C run-time before implementations were built for
those operating systems.
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.


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

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