由买买提看人间百态

topics

全部话题 - 话题: fptest
(共0页)
b***y
发帖数: 2799
1
来自主题: Programming版 - [合集] Why it only write the file once?
☆─────────────────────────────────────☆
baodong (馋懒大魔包) 于 (Fri Sep 23 13:28:48 2005) 提到:
Hello, I do not understand why the following code only wrote the test.txt once
. If I comment out "if (!fpTest)", it works. Why is it different with "if (!
fpTest)"???
#include
int main(void)
{
FILE* fpTest = NULL;
for (int i=0; i<5; i++)
{
if (!fpTest)
fpTest =fopen("test.txt", "w");
fprintf(fpTest, "%d\n", i);
fflush(fpTest);
fclose(fpT
(共0页)