Hi I am new to C++ programming and I am in some need of help. I need to write a program that opens a file called "in.dat", reads it character by character and converts all lower case characters to upper case. The program then needs to write this output to a file called "out.dat" and outputs its contents to the screen. This is what I have so far:
Code:
#include <iostream>
#include <cctype>
#include <fstream>
using namespace std;
int main()
{
ifstream inFile("in.dat");
ofstream outFile("out.dat");
if (!inFile)
{
cout << "Input file not open" << endl;
return -1;
}
if (!outFile)
{
cout << "Output file not open" << endl;
return -1;
}
char ch;
while (ch = inFile.get())
{
cout.put(ch);
outFile.put(ch);
}
inFile.close();
outFile.close();
return 0;
}
I already have some text for "in.dat" but this code only loops a character infinitely to the screen. Any help would be appreciated. Thanks.