From e0c01fe3217ed14f64279b46d9b9b456d08bba6a Mon Sep 17 00:00:00 2001 From: Misha Date: Tue, 4 Nov 2025 18:47:39 +0200 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20Task4.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Task4.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Task4.cpp 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