实例:
#include <stdio.h>
int main()
{
FILE *fpWrite=fopen("hello.txt","w");
if(fpWrite==NULL)
{
return 0;
}
for(int i=0;i<10;i++)
fprintf(fpWrite,"%d ",i);
fclose(fpWrite);
//下面是调用
int a[10]={0};
FILE *fpRead=fopen("hello.txt","r");
if(fpRead==NULL)
{
return 0;
}
for(int i=0;i<10;i++)
{
fscanf(fpRead,"%d ",&a[i]);
printf("%d ",a[i]);
}
getchar();
return 1;
}