读取a.txt中文本,统计文本中字母数量,用C语言解答?

实训作业实在是写不出来,求助

读取a.txt中文本,统计文本中字母数量

哈哈哈哈哈🤣🤣🤣,先容我笑会,CSDN 还有其他的地方不是有很多吗

网页链接


或者直接使用上面的这个,我刚用VS2019编译了,可以成功,input.txt,在C文件同级目录

#include <iostream>#include <iomanip>#include <fstream>using namespace std;int main(){    ifstream fin("input.txt");    if(!fin)    {        cout << "file error!"<<endl;        exit(0);    }    char str;    int count = 0;    while(!fin.eof())    {        fin >> str;        if(( str >= 'a' && str <= 'z' )  || ( str >= 'A' && str <= 'Z' ))        {            ++count;        }    }    fin.close();    cout << "the engish is " << count << endl;    return 0;}追问

编译错误,过不了

温馨提示:答案为网友推荐,仅供参考
相似回答