#include <iostream>
#include <string>
#include <vector>
int main() {
setlocale(LC_ALL, "RU");
std::string input;
std::vector<char> charVector;
int count = 0;
std::cout << "ctrl + z 4 end read" << std::endl;
std::string line;
while (std::getline(std::cin, line)) {
input += line;
}
for (char c : input) {
charVector.push_back(c);
}
for (int i = 0; i < charVector.size(); i++) {
if (charVector[i] == 'а' || charVector[i] == 'б' || charVector[i] == 'в' || charVector[i] == 'г' || charVector[i] == 'д' ||
charVector[i] == 'е' || charVector[i] == 'ё' || charVector[i] == 'ж' || charVector[i] == 'з' || charVector[i] == 'и' ||
charVector[i] == 'й' || charVector[i] == 'к' || charVector[i] == 'л' || charVector[i] == 'м' || charVector[i] == 'н' ||
charVector[i] == 'о' || charVector[i] == 'п' || charVector[i] == 'р' || charVector[i] == 'с' || charVector[i] == 'т' ||
charVector[i] == 'у' || charVector[i] == 'ф' || charVector[i] == 'х' || charVector[i] == 'ц' || charVector[i] == 'ч' ||
charVector[i] == 'ш' || charVector[i] == 'щ' || charVector[i] == 'ъ' || charVector[i] == 'ы' || charVector[i] == 'ь' ||
charVector[i] == 'э' || charVector[i] == 'ю' || charVector[i] == 'я') {
count++;
}
}
std::cout << "count rusbukv " << count << std::endl;
return 0;
}
считать количество русских букв, однако он не правильно это делает, что не так?
setlocale(LC_ALL, "");
const char *str = input.c_str();
while (*str) {
wchar_t c;
int n = mbtowc(&c, str, MB_CUR_MAX);
if (n < 0)
break;
if (wcschr(L"абвгд...юя", c))
++count;
str += n;
}