主题:哪位高手看看我这个程序,我编了三个小时了……就一个问题
关于文件的:对指定的文件进行读写,就算该文件有多少个单词。各位高手运行一下就知道有什么错误了,我就是不知道怎么改…………
#include<stdio.h>
#include<stdlib.h>
void main()
{
char ch;
int n=0;
FILE *fp;
if((fp=fopen("34.txt","r"))==NULL)
{
printf("Can't open file\n");
exit(0);
}
while(!feof(fp))
{
ch=fgetc(fp);
while(ch==' ')
{ch=fgetc(fp);putchar(ch);}
while(ch!=' ')
{ch=fgetc(fp);putchar(ch);}
n=n+1;
}
fclose(fp);
printf(":%d\n",n);
}[em8][em8]
#include<stdio.h>
#include<stdlib.h>
void main()
{
char ch;
int n=0;
FILE *fp;
if((fp=fopen("34.txt","r"))==NULL)
{
printf("Can't open file\n");
exit(0);
}
while(!feof(fp))
{
ch=fgetc(fp);
while(ch==' ')
{ch=fgetc(fp);putchar(ch);}
while(ch!=' ')
{ch=fgetc(fp);putchar(ch);}
n=n+1;
}
fclose(fp);
printf(":%d\n",n);
}[em8][em8]