I need to write a program that reads a text file and counts the characters in each line. The program should display the line number and the length of the shortest and longest lines in the file, as well as the average number of characters per line...This is what I have but having issues finishing it off....

#include <iostream>
#include <fstream>
#include <string>
#include <cassert>
using namespace std;
bool characterCount(char);

int main ()
{
//Describe the program to the user
cout << "This program reads a text file and counts the characters in each line!" << endl;

//INPUT SECTION
//Input the file
cout << "Enter the name of the input file: ";
char inputFilename[80];
int i;
cin.getline(inputFilename, 80);

//Open an input stream to the input file
//Establish a connection
ifstream fin;

//Check for success
fin.open(inputFilename);

//Implementation of the input file
//Declare variables
int count = 0, sum = 0;
char reading;

//For statemen to calculate
for(;
{
//Read a value from file
fin >> reading;

//If eof, quit
if (fin.eof()) break;
if (characterCount(reading))

//Update the count
count++;
}

//OUTPUT SECTION
//output the file
cout << "Enter the name of the output file: ";
char outputFilename[80];
cin >> outputFilename;

//Open an output stream to the output file
ofstream fout;
fout.open(outputFilename);

//Check for success
asset(fout.is_open());

//Write results to file

//Close the stream
fout.close());
cout << "Processing complete!" << endl;

//Return a value
return 0;
}

bool characterCount(char in)
{
bool value = false;
switch (in)
{
case 'a':
case 'A':
case 'b':
case 'B':
case 'c':
case 'C':
case 'd':
case 'D':
case 'e':
case 'E':
case 'f':
case 'F':
case 'g':
case 'G':
case 'h':
case 'H':
case 'i':
case 'I':
case 'j':
case 'J':
case 'k':
case 'K':
case 'l':
case 'L':
case 'm':
case 'M':
case 'n':
case 'N':
case 'o':
case 'O':
case 'p':
case 'P':
case 'q':
case 'Q':
case 'r':
case 'R':
case 's':
case 'S':
case 't':
case 'T':
case 'u':
case 'U':
case 'v':
case 'V':
case 'w':
case 'W':
case 'x':
case 'X':
case 'y':
case 'Y':
case 'z':
case 'Z':

value = true;
}
//Return a value
return value;
}

#1) Use CODE Tags
#2) Format your code so we can follow it
#3) Are we supposed to guess what issues you are having?
#4) You don't need a switch statement, especially one like that

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.