c语言文件读入

int read(int arr[]){
int i=0,n,flag=0;
FILE *fp;
if((fp=fopen("shuru.txt","r"))==NULL){
printf("cantfind the file");
}
while(!feof(fp)){
if(flag==0){
fscanf(fp,"%d",&n);
flag=1;
}
else{
fscanf(fp,"%d",&arr[i++]);
}
}
fclose(fp);

return n;
}

posted @ 2020-09-18 10:49  反语owo  阅读(94)  评论(0编辑  收藏  举报