实验十一 文件操作 程序二

输出文本文件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! ");
exit(0);
}
while(!feof(fp)){
ch=fgetc(fp);
if(ch!=' '){
printf("%c",ch);
}
}
if(fclose(fp)){
printf("Can not close the file! ");
exit(0);
}
return 0;
}

原文地址:https://www.cnblogs.com/ars134419622/p/10179184.html