File Content Switched to All CAPS

Hello,
I am having such a hard time even getting this program to run; thus far, I have started to create (or think I am creating) a file with a user input filename-- I haven't even started to get all letters to be changed to caps, however. Any help with this would be much appreciated, I'm stumped!

Exercise: Create a program that reads a text file and prints out the contents of the file but will all letters converted to uppercase.

The name of the file to be read by the program should be typed in by the user.

Here are some example sessions:

User input:
data.txt

Contents of "data.txt":
Hello, World!

Program output:
HELLO, WORLD!

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

User input:
data.txt

Contents of "data.txt":
tHiS FiLe
HaS
mIxEd CaSeS

Program output:
THIS FILE
HAS
MIXED CASES

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
int main() {
	ifstream inFS;
	string fileStr;
	string filename = " ";

	cout << "Enter filename: " << endl;
	cin >> filename;

	inFS.open(filename);

	if (!inFS.is_open()) {
		cout << "Could not open file " << filename << endl;
		system("pause");
		return 1;
	}

	inFS >> fileStr;
	inFS.close();

	cout << fileStr << endl;

	system("pause");
	return 0;
}
Change line 17 to
1
2
   char c;
   while ( inFS.get( c ) ) cout.put( toupper( c ) );


Remove lines 3 and 20 and include the header <cctype>. That's about it.

Topic archived. No new replies allowed.