#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
ifstream in("input.txt");
if (!in.good())
{
cerr << "Unable to open " << input << endl;
exit(1);
}
ofstream out("output.txt");
if (!out.good())
{
cerr << "Unable to open " << output << endl;
exit(1);
}
int c;
while ((c = in.get()) != EOF)
switch(c)
{
case 'a':
out << 'A';
break;
default:
out << (char)c;
break;
}
// alternate
/*while ((c = in.get()) != EOF)
if (c == 'a')
out << 'A';
else
out << (char)c;*/
return 0;
}
The variable and while loop can also be written as:
char c;
while (in.get(c))