Program to stream in and analyze a text file

Write a program to analyze a text file. Read each character from the file, and keep track of the following:

The total number of characters 
The total number of alpha characters (a-z, A-Z) 
The total number of numerals (0-9) 
The total number of a single specified character. (Ask the user which character they wish to search for). 
The total number of lines. (Think about this)

Output results to the screen, and also to a file. Use setw(), right, left, setfill() etc. to format your output in a table format. Create your own text file for testing. I'm totally lost on this. Please help.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
 /*************
Program Name: 
Programmer: 	                      
Description: 
Date Written:
**************/

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

// Declare constants

// Function Prototypes

int main()
{
	// Declare variables below here
	string fileName;
	char x;
	int charCount, alphaCount, numCount, spefCount, lineCount;
	ifstream infile;
	ofstream outfile;
	// Initialization Section for real number output. DO NOT MOVE!
	cout <<setiosflags(ios::fixed | ios::showpoint);
	cout <<setprecision(2);
	// Begin your "main processing" below here
	cout<<"Please enter the file name >> ";
	cin>>fileName;

	infile.open(fileName);

	cout<<"Please enter a single specific character to search for: "<<endl;
	cin>>x;



	cout<<"Number of characters: "<<charCount;
	cout<<"Number of alpha characters (a-z): "<<alphaCount;
	cout<<"Number of numeric characters (0-9): "<<numCount;
	cout<<"Number of user specified characters: "<<spefCount;
	cout<<"Number of lines: "<<lineCount;

	return 0;
}

// function definitions below here 
Topic archived. No new replies allowed.