diff --git a/Task4.cpp b/Task4.cpp new file mode 100644 index 0000000..e2e63a0 --- /dev/null +++ b/Task4.cpp @@ -0,0 +1,32 @@ +#include +#include + +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"); +} \ No newline at end of file