Files
IT-Step/Task4.cpp
2025-11-04 18:47:39 +02:00

32 lines
552 B
C++

#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");
}