counters program wanna see if on right track

this program should be able to
Given a file of text, assume that
a "word" is 1 or more consecutive, non-whitespace characters
a "sentence" is a series of words terminated by either a period, exclamation point, or question mark
Design a C++ program (using functions/passing parameters) that will

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


this is what i have so far
#include <string>
#include <fstream>
#include <iomanip>
#include <cctype>
using namespace std;

void getfilename (string, string&);
void format (string&);
void count_cons (string, int&);
void count_sen (string, int&);
void count_word (string, int&);
void count_char (char, int&);

int main ()

{

ifstream input;
ofstream output;
string data;
string getfilename;

string word;
string sterm;
char ch;
int sentences = 0;
int letters = 0;
int consonants = 0;
int nonwhitespaces = 0;
int search_hits = 0;
int a[256] = {0};
char consonants[42] = { 'B', 'b', 'c', 'C', 'd', 'D', 'f', 'F', 'g', 'G', 'h'\
, 'H', 'j', 'J', 'k', 'K', 'l', 'L', 'm', 'M', 'n', 'N', 'p', 'P', 'q', 'Q', 'r\
', 'R', 's', 'S', 't', 'T', 'v', 'V', 'w', 'W', 'x', 'X', 'y', 'Y', 'z', 'Z'}
getfilename ( "input", filename);
input.open ( filename.c_str());
getfilename ( "output", filename);
out.open (filename.c_str());
cout << "Please enter the name of your input file" << endl;
cin >> filename;
cout << "Please enter the search string" << endl;
cin >> sterm;
input >> data;
while (input)
{
count_letter( data, letters&);
count_consonants ( data, consonants&);
count_sentences ( data, sentences&);
count_char (data,nonwhitespaces&);
count_search ( data, search_hits);

void count_letter ( data, letters&)
{
if ((( data >= 'a' ) && ( data <= 'z')) || (( data >= 'A' && (data <= 'Z'))\
)
letters ++;

}

void count_words (data, words&)
{


for ( int c=0; data[c] != '\0'; c++)
{
++a[data [c]];
if (data [c] == ' ' && data [c+1] != '\0')
{
words ++;
}
}
}
void count_cons (data, consonants&)
{
for ( int i = 0; i <42 ; i++)
if ( data == consonants[i]
{
consonants ++;
i = 42;
}
}
void count_sen (data, sentences&)
{
char finished; if (finished == '?' || finished == '!' || finished == '.');
sentences ++;

}
void count_char ( data, nonwhitespaces&)
{
nonwhitespaces = 0;
char ch;
cin.get(ch);
if (ch == '!' || ch == '?' || ch == '.' || ch == '"' || ch == ';')
nonwhitespaces ++;

char finished = word[ word.length()-1];
if (finished == '?' || finished == '!' || finished == '.');
sentences ++;

}
void count_char ( data, nonwhitespaces&)
{
nonwhitespaces = 0;
char ch;
cin.get(ch);
if (ch == '!' || ch == '?' || ch == '.' || ch == '"' || ch == ';')
nonwhitespaces ++;



am i on the right track?




Topic archived. No new replies allowed.