91学习

陪伴你每一天!

fscanf()函数读取fp所指向的文件中的i的值

#include <stdio.h>

#include <process.h>


void main(){

FILE *fp;

char i,j;

char filename[30];

printf("please input the filename:\n");

scanf("%s",filename);

while((fp=fopen(filename,"r"))==NULL){

printf("can not open file:\npress any key to continue:\n");

getchar();

exit(0);

}

for(i=0;i<5;i++){

fscanf(fp,"%c",&j);

printf("%d is %5d\n",i+1,j);

}

fclose(fp);

}

加威信18790284560免费送POS机.jpg

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。