C语言中,如何把数组里的数据写入文件?
1个回答
展开全部
帮你写了个简单的你看看就知道怎么写入了:)#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();}
#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();}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询