重定向式
#include<stdio.h>
int main()
{
freopen("in.text","r",stdin);
freopen("out.text","w",stdout);
int n,a,b;
scanf("%d%d",&a,&b);
printf("******%d\n",a+b);
return 0;
}
非重定向式
#include<stdio.h>
int main()
{
FILE *fin,*fout;
fin=fopen("data.in","rb");
fout=fopen("data.out","wb");
int n,a,b;
fscanf(fin,"%d%d",&a,&b);
fprintf(fout,"******%d\n",a+b);
fclose(fin);
fclose(fout);
return 0;
}
文件读写重定向式与非重定向式
最新推荐文章于 2023-08-07 13:49:27 发布