interactively prompt for and read the name of an input file
interactively prompt for and read a string to search for
open the input file (using an input filestream variable) and with one pass through the file
count the number of "words" in the file
for each word, make sure all letters, except the first, are lower case - leave the first character unchanged
count the number of "sentences" in the file
count the number of letters in the file (A-Z,a-z)
count the number of consonants in the file (consonants are letters that are not vowels - the vowels are: a, e, i, o, u, A, E, I, O, and U)
count the number of nonwhitespace characters in the file that are NOT letters
count the number of times the search string is found in the file (must be an exact match) - search for matches AFTER upper case letters have been coverted to lower case
required output (all output should be displayed on the screen)
display a message that provides the name of the input file
display the contents of the file so that each word on a line is separated by exactly 1 blank space and there are no more than 40 characters per line (including blanks); you must display the maximum number of whole words that will fit on a line without exceeding 40 characters
when the entire file has been read and displayed, display the 6 counts made with appropriate labels; when displaying the search string count, you MUST display the string enclosed in quotes as part of the label; leave at least one blank line between the end of the file and the counts
close the input file
#include <iostream>
#include <fstream>
#include <string>
usingnamespace std;
int main()
{
ifstream fin;
string tempstr, keyword;
cout << "Enter name of file to search through: ";
cin >> tempstr;
fin.open(tempstr.c_str());
cout << "Enter keyword to search for: ";
cin >> keyword;
//declare all your counters
while (fin >> tempstr)
{
//all your counters should be doing stuff in here
}
//output your results here
return 0;
}
cout << "Please enter the name of the input file " << endl;
cin >> file;
input.open (filename.c_str());
cout << "Please enter the search string " << endl;
cin >> sterm;
while (input)
{
if ( ch == '\n')
numLines ++;
if (((file >= 'a' ) && (ch <= 'z'))|| ((ch >= 'A' && (ch <= 'Z')))
numChars ++;
}