- 论坛徽章:
- 0
|
本帖最后由 106033177 于 2012-09-21 09:03 编辑
回复 1# wpdzyx
这个程序是错误的。读和写不能紧挨着 这个c标准是明确指出了,你非要违反标准,那么程序的行为取决于具体的c实现,如果你用微软的 runtime的话 结果是文件内容没有任何改变。
When a file is opened with update mode ('+' as the second or third character in the
above list of mode argument values), both input and output may be performed on the
associated stream. However, output shall not be directly followed by input without an
intervening call to the fflush function or to a file positioning function (fseek,
fsetpos,or rewind), and input shall not be directly followed by output without an
intervening call to a file positioning function, unless the input operation encounters end-
of-file.
|
|