FOPEN [英] fopen

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

问题描述

我有一个关于fopen的问题。我想将文本附加到文本文件

已写入。我认为这是我需要做的。如果我是正确的fopen''s

第二个参数只需要2个字母。我正在使用wt。如果我的文本文件还没有包含

的wa或+ +,要附加文本我将需要另一个fopen调用吗?如何检查以前创建的现有文本文件是否为



Bill

I have a question about fopen. I want to append text to a text file
already written. I think this is what I need to do. If I am correct fopen''s
second parameter takes only 2 letters. I am using wt. To append text would I
need another call to fopen if my text file isn''t already existing consisting
of wa or a+ ? How can I check if an existing text file exists that has been
created before ?

Bill

推荐答案

在文章< VgA5k.40538
In article <VgA5k.40538


lE3.23882@trnddc05>,

Bill Cunningham< no **** @ nspam.comwrote:
lE3.23882@trnddc05>,
Bill Cunningham <no****@nspam.comwrote:

我有一个关于fopen的问题。我想将文本追加到已经写好的文本文件中。我认为这是我需要做的。如果我是正确的fopen''s
第二个参数只需要2个字母。
I have a question about fopen. I want to append text to a text file
already written. I think this is what I need to do. If I am correct fopen''s
second parameter takes only 2 letters.



不,有明确定义的三字符序列。

No, there are well-defined three-character sequences.


>我正在使用wt 。
>I am using wt.



标准没有定义''t''的含义,只定义''b''(二进制)。

Text如果没有指定二进制,则假设。

The standard does not define the meaning of ''t'', only of ''b'' (binary).
Text is assumed if binary is not specified.


如果我的文本文件尚未包含,则我需要另外调用fopen wa或a +?如何检查以前创建的现有文本文件是否存在?
To append text would I
need another call to fopen if my text file isn''t already existing consisting
of wa or a+ ? How can I check if an existing text file exists that has been
created before ?



fopen()with''a''。 ftell()你当前的位置,fseek()到

文件的开头,再次ftell()。如果第一个ftell()

结果与第二个ftell()相同,那么你开始在文件的开头

,因此没有现有的文本。


(注意:如果我没记错的话,在某些系统中使用文本流时,

初始文件位置被正式认为是过去一段时间。

文件的结尾,而不是右边的-at-文件的结尾。写的

仍然以相同的方式工作,但如果我的记忆在这一点上是正确的,

然后新创建的文本文件上的ftell()可能不会从同一文件的开头返回与ftell()相同的值。)< br $> b $ b -

"无数各种思想和竞争对手的产品,紧凑的

模糊和微小的联想,一种语言有它自己的丰富并且

经常引用法律,以及奖学金所包含的

的习惯性和总结性认可。 - Walter Pater

fopen() with ''a''. ftell() your current position, fseek() to the
beginning of the file, and ftell() again. If the first ftell()
result is the same as the second ftell() then you started out at
the beginning of the file and so there was no existing text.

(Note: If I recall correctly, in some systems when using text streams,
the initial file position is officially considered to be "one past"
the end of file, rather than right -at- the end of file. The writes
still work the same way, but if my memory is correct on this point,
then ftell() on a newly-created text file might not return the
same value as ftell() from the "beginning" of the same file.)
--
"Product of a myriad various minds and contending tongues, compact of
obscure and minute association, a language has its own abundant and
often recondite laws, in the habitual and summary recognition of
which scholarship consists." -- Walter Pater




" Bill Cunningham" < no **** @ nspam.comschreef in bericht

news:VgA5k.40538

"Bill Cunningham" <no****@nspam.comschreef in bericht
news:VgA5k.40538


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

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