实验十一 文件操作 程序二

输出文本文件input.txt中的非空格字符。

如程序一中的操作,重命名为input

 

 

#include<stdio.h>
#include<stdlib.h>
int main()
{
FILE *fp;
char ch;
if((fp=fopen("D:\\wj\\input.txt","r"))==NULL){
printf("File open error!\n");
exit(0);
}
while(!feof(fp)){
ch=fgetc(fp);
if(ch!=' '){
printf("%c",ch);
}
}
if(fclose(fp)){
printf("Can not close the file!\n");
exit(0);
}
return 0;
}

posted @ 2018-12-26 15:01  阿森纳必胜  阅读(216)  评论(0编辑  收藏  举报