c语言程序设计txt急

来源:百度知道 编辑:UC知道 时间:2024/05/27 02:20:00
写一个程序,把数据存到.TXT里面~
在线等,高手快来啊
晕,你写一个简单点的程序好吗?
比如我定义一个
int a = 4;
把a的值存在.txt文件里。OK?

void main(){
FILE *fp=fopen("a.txt","w+");
int a=4;
fprintf(fp,"%d",a);
fclose(fp);
}

不仅能存数据还能比较文件相似度。。。。
#include"stdio.h"
#include"string.h"
#define N(a,b) 2.0*a/b*100
FILE *pa,*pb;
int t,m;
char a[100],b[100];
/*创建文件1*/
void Creat1_Z()
{
if((pa=fopen("d:\\file1.txt","w+"))==NULL)
printf("\tCannot open this file!\n");
else
{ printf("\tEnter a string to File1:\n");
getchar();
gets(a);
fputs(a,pa);
printf("\tSuccess!\n");
}
fclose(pa);
}
/*创建文件2*/
void Creat2_Z()
{
if((pb=fopen("d:\\file2.txt","w+"))==NULL)
printf("\tCannot open this file!\n");
else
{ printf("\tEnter a string to File2:\n");
getch