c++ 如何把数组数据写入文件

最好用 fprintf

第1个回答  推荐于2016-10-09
帮你写了个简单的你看看就知道怎么写入了:)

#include"stdio.h"
#define MAX 1000
main()
{FILE *fp;
int
i=0;
char sky[MAX];
printf("please
input:\n>>");
gets(sky);
fp=fopen("001.txt","w");
while(sky[i]!='\0'
)
{fprintf(fp,"%c",sky[i]);
i++;
}
;
fclose(fp);
printf("write over!");
getch();

}本回答被提问者采纳
相似回答