I got a problem about File I/O stream. I have created a text file which is called input.txt which contains 80 characters in each line. The follwoing codes I did typed, but, I don't know how to use the input file to calculate the numbers of upper cases and the numbers of lines. Please help me!
#include <iostream>
#include <string>
using namespace std;
#include <fstream>
int main()
	ifstream fin1 ("input.txt");
	if (!fin1)
		cout << "Cannot open infile: input.txt\n";
		cout << "Infile: input.txt opened.\n";
		cout << "Number of spaces: ";
		char ch[1000];
		int numchar = strlen(ch);
		int count1 = 0;
		for (int i=0;i<numchar;i++)
				if (ch[i] == ' ')
		cout << count1;
		cout << endl;
		cout << "Number of upper cases: ";
		int sum1 = 0;
		for (int i=0; i<numchar;i++)
			if (isupper(*ch))
		cout << sum1;
		cout << endl;
		cout << "Number of lines: ";
		cout << endl;
	return 0;
Thanks a lot!!!

Last edited by shabbir; 19Jan2007 at 14:40.. Reason: Code formatting.