Добавить Task4.cpp

This commit is contained in:
2025-11-04 18:47:39 +02:00
parent ad94106e74
commit e0c01fe321

32
Task4.cpp Normal file
View File

@@ -0,0 +1,32 @@
#include <iostream>
#include <fstream>
using namespace std;
int main() {
ifstream fin("..\\MyFile\\info.txt");
if (!fin) {
cout << "Error: open input file!!\n";
system("pause");
return 1;
}
char s[100];
char a;
int count = 0;
cout << "Enter the character:";
cin >> a;
while (fin >> s) {
if (tolower(s[0]) == tolower(a)) {
count++;
}
}
cout << "Number of words starting with '" << a << "': " << count << endl;
fin.close();
system("pause");
}