We wish to write a program countletter.cpp that takes a filename and a single character on the command line and prints the number of occurrences of that character in the file (case sensitive).
For example, if foo.txt contains
this is a test
foo.txt contains 3 of t
Please finish the code below. Remember:
- We do not have any spaces in the answer.
- There are 2 times try only. It's better if you can get 100% correct. If you are not, we'll check for you by ourself!
#include <$1> // Line 1
using namespace std;
$2 filename, letter; // Line 2
cout << "What file would you like to open?";
cin >> $3; // Line 3
cout << "\nWhat letter would you like to count?";
cin >> letter;
cout << $4 << " not found\n"; // Line 4
int count = 0;
if ($5) // Line 5
cout << filename << " contains "
<< $6 << " of " << letter << "\n"; // Line 6