Little Program
Hello mpgh'ers,
I have a problem with my C++ program.
This was the assignment:
And I wrote this:
[HIGHLIGHT=Java]#include <iostream>
#include <cctype>
using namespace std;
int main()
{
char ch;
char line[100];
int i = 0;
cin.get(ch);
while(ch != '@')
{
if(isdigit(ch))
i -= 1;
else if(islower(ch))
{
toupper(ch);
line[i] = ch;
}
else if(isupper(ch))
{
tolower(ch);
line[i] = ch;
}
else
line[i] = ch;
i++;
cin.get(ch);
}
line[i] = '\0';
cout << line;
cout << endl;
system("pause");
return 0;
}[/HIGHLIGHT]
But it shows this:

Anyone know what wrong?
Edit: Changed the code to what I have now. And everything works except the toupper() and tolower().
I have a problem with my C++ program.
This was the assignment:
Write a program that reads keyboard input to the @ symbol and that echoes the input except for digits, converting each uppercase character to lowercase, and vice versa.
[HIGHLIGHT=Java]#include <iostream>
#include <cctype>
using namespace std;
int main()
{
char ch;
char line[100];
int i = 0;
cin.get(ch);
while(ch != '@')
{
if(isdigit(ch))
i -= 1;
else if(islower(ch))
{
toupper(ch);
line[i] = ch;
}
else if(isupper(ch))
{
tolower(ch);
line[i] = ch;
}
else
line[i] = ch;
i++;
cin.get(ch);
}
line[i] = '\0';
cout << line;
cout << endl;
system("pause");
return 0;
}[/HIGHLIGHT]
But it shows this:

Anyone know what wrong?
Edit: Changed the code to what I have now. And everything works except the toupper() and tolower().

)