Opening a file in 'a+ 'mode

后端 未结 3 1454
感情败类
感情败类 2020-12-20 15:44

If a file is opened using the following command:

FILE *f1=fopen(\"test.dat\",\"a+\");

The man page reads:

a+

3条回答
  •  遥遥无期
    2020-12-20 16:19

    You can never mix reading and writing operations on a FILE without calling fseek in between. It may work as you wish on some implementations, but a program that depends on this has undefined behavior. Thus the questions of having 2 positions is meaningless.

提交回复
热议问题