Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e0c01fe321 |
32
Task4.cpp
Normal file
32
Task4.cpp
Normal 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");
|
||||
}
|
||||
Reference in New Issue
Block a user