Hi!
Im trying to write a code that replaces the first letter of every line with a capital letter.
So for starters that would be the part of the code for replacing.
The problem:
for ex. input : abc
output: aAbBC
It only replaces the last letter and not the first ones.
Maybe im using the wrong funtion for that. Thanks.
Code:
#include <iostream>
using namespace std;
int main()
{
char ch;
cout << "Enter a phrase: ";
while ( cin.get(ch))
{
if (ch == 'a')
cin.putback('A');
if (ch == 'b')
cin.putback('B');
if (ch == 'c')
cin.putback('C');
else
cout << ch;
}
system("PAUSE");
return 0;
}