计算数组中的字母.C++
Counting letters in an array. C++
很抱歉,如果措辞/术语不尽可能准确,我对这种编码方法还比较陌生。
所以我有一个名为somefile.txt的.txt文件该文件的内容如下:
24 234 14
a8 267 35
35 378 28
b5 467 29
文件加载如下:
#include <iostream>
#include <istream>
#include <fstream>
#include <string>
int main (){
ifstream inputfile;
inputfile.open("somefile.txt");
string contents;
while(!inputfile.eof())
{
getline(inputfile, contents);
cout << contents;
}
inputfile.close();
}
我现在想做的是找出这个文件和其他相同格式和类似.txt文件中有多少个字母。例如,somefile.txt有两个字母,当人类看到文件内容时,它们可以被识别。有没有办法让计算机知道/计算有多少个字母。我还希望,如果可能的话,这可以在一个单独的功能中完成。
希望这能澄清我以前糟糕的写作。再次感谢
查看ctype.h并使用isletter或isalpha等。http://www.cplusplus.com/reference/cctype/
相关文章:
- Mongodb c++驱动程序:如何查询元素的数组
- 将数组的地址分配给变量并删除
- 从C++本机插件更新Vector3数组
- lambda参数转换为constexpr技巧,然后获取带链接的数组
- 将数组作为参数传递给函数安全吗?作为第三方职能部门,可以探索他们想要的之外的其他元素
- 数组索引的值没有增加
- 将对象数组的引用传递给函数
- 为char数组调整zlib-zpipe
- 2D数组来自文本输入,中间有空格
- std::向量与传递值的动态数组
- 在c++中用vector填充一个简单的动态数组
- 使用strcpy将char数组的元素复制到另一个数组
- 使用指针从C++中的数组中获取最大值
- C++使用整数的压缩数组初始化对象
- 告诉一个 const char 数组,除了编译时 C 样式的字符串外,它不以 '