English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

#include
using namespace std;
int main()
{
char ch;
cout<<"enter characters followed by'~'";
cin.get(ch);
while(ch!='~')
{
if(ch>='a' && ch<='z')
{
ch=ch-32;
cout< }
else if(ch>='A' && ch<='Z')
{
ch=ch+32;
cout< }
}

return 0;
}

2007-03-06 05:11:30 · 4 answers · asked by sirf _tum 1 in Computers & Internet Programming & Design

4 answers

check out this link:

http://blog.chilkatsoft.com/?p=23

shows the use of TOUPPER and TOLOWER... not sure if that's what you are trying to do, but might spark an idea or two.

also check out this:
http://www.daniweb.com/techtalkforums/thread13727.html

2007-03-06 05:16:13 · answer #1 · answered by Pitchy 5 · 0 0

/*
* Convert the input file to all upper case.
*/
#include
#include

using namespace std;

int main()
{
char inch; // Input character.

while(cin.get(inch)) {
if(isalpha(inch))
cout << (char)toupper(inch);
else
cout << inch;
}
}

Here is an example..
Your method may also work, if you are getting an asci value instead of a character it is probably because you forgot to cast the variable. cast it with (char)variable_name in your cout.

2007-03-06 05:25:00 · answer #2 · answered by joec_11 3 · 0 0

The way I remember when I did that kind of stuff, the capitals where lower down, the lower case letters were higher up. You seem to also convert uppers to lowers? You may be undoing what you just did before.

2007-03-06 05:17:05 · answer #3 · answered by Anonymous · 0 0

seems like alot of code to convert to uppercase, if i remember right in visual basic its only 1 line of code, so C__ cant be that complex...

2007-03-06 05:15:07 · answer #4 · answered by jwalker343 3 · 0 0

fedest.com, questions and answers