Ive been asked to write a program that reads a text file and counts the number of characters used, counts the number of words used and then divides the two sums to obtain the average word length of the document.
I have the amount of characters... almost I cant figure out how to omit the symbols, the spaces and the beginning or ending of a line. and i think that the condition for the words would be similar but defined as a string? I dont know I'm really stuck and any help at all would be greatly appreciated
using namespace std;
int main( )
cout << "input file could not be opened" << endl;
int word_number=0, character_number=0;
cout << letter;
cout << "the total charecter count is " << character_number << endl;
cout << "the total word count is " << word_number << endl;
cout << "the average word length is " << average << endl;
I changed it a little and now it crashes right before line 37
The variable word_count is never modified throughout the program so the value remains zero (what it was initialized to in its definition). When you attempt to perform a division operation on (two int values) character_count and word_count (always zero), the result is undefined so your program crashes.