Counting characters, then output total

I'm writing a program that counts characters from a file, and outputs the answer to the screen. I've got some code, but I'm really confused on getting the answer I want.


#include <fstream>
#include <iostream>
#include <iomanip>
using namespace std;

int main ()

{
ifstream FileIn;
ofstream Fileout;
int count=0;
char inchar;


FileIn.open("E:\\CFiles\\QUOTES.txt");
Fileout.open("E:\\Answers.txt");

while (FileIn)
{

count=0;
FileIn.get(inchar);

while(inchar>='A'&&inchar<='Z'||inchar>='a'&&inchar<='z')
{count++;
FileIn.get(inchar);
}

if (count==3)
count; //What goes here?????????????????

else if (count==4)
count; //And here????????????????

else if (count==5)
count; //And here???????????

else if (count==6)
count;


cout<<"3 letter words "<<??????<<endl;
cout<<"4 letter words "<<??????<<endl;

}


FileIn.close();
FileIn.clear ();
}

What is the problem, exactly?
You might want to get used to using parenthesize with your logical operators.

while( (inchar >= 'A' && inchar <= 'Z' ) || (inchar >= 'a' && inchar <= 'z') )

for example.
Last edited on
Here are the instructions, verbatim: Write a program to read a file called (QUOTES.TXT). Your program will count all 3, 4, 5, and 6 letter words. Display the results in the following format:

3 letter words :xxx
4 letter words: xxx
5 letter words: xxx
6 letter words: xxx

The input for this program comes from a file.
Topic archived. No new replies allowed.