我有以下dlang语言代码import stdstdio;void main auto file1 = Fileexampletxt w; file1writelnHello world!; auto file2 = Fileexampletxt r; writelnfile2name; 输出 exampletxt file2readln; 读取 Hello wo
这是因为在执行完写入操作后,文件指针已经到达了文件末尾,而没有执行写入操作的时候,文件指针是在文件开头的位置。当执行读取操作时,文件指针会向后移动,直到到达文件末尾,此时eof为true。因此,保留写入操作的代码时,文件指针并没有到达文件末尾,执行读取操作时eof为false。
原文地址: https://www.cveoy.top/t/topic/gKKk 著作权归作者所有。请勿转载和采集!