//2018/4/21 文件的使用
#include<stdio.h>
#include<stdlib.h>//exit
#include<string.h>
#include<ctype.h>
#define N 100
//以下函數是什麼意思?
/*
fclose();
feof();
fgetc()'
fgets();
fopen();
fputc();
fputs();
fread();//2針對2進制文件
fseek();
fwrire();//2
getc();
getchar();
getw();
putchar();
puts();
putw();
getchar();
*/
int main()
{
char ar[N];
FILE *fp = fopen("wmll.txt","r");
if(fp==NULL)
{
printf("open error!\n");
exit(1);
}
for(int i=0;i<10;i++)
{
fscanf(fp,"%d ",&ar[i]);//這個函數基本沒有使用的意義
}
fclose(fp);
fp = NULL;
return 0;
}
/*int main()
{
char ar[N]={"lihenghui love wml!"};
FILE *fp = fopen("wmll.txt","w");
if(fp==NULL)
{
printf("open error!\n");
exit(1);
}
for(int i=0;i<N;i++)
{
fprintf(fp,"%d ",ar[i]);////這個函數基本沒有使用的意義
}
fclose(fp);
fp = NULL;
return 0;
}
*/
c語言文件函數的使用
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.