kensy11
asked on
convert lower case to upper case
Hallo,
i am working on a program , it ask for a character and it gives an error if its a number
Now the next thing i want to do is if we give a character in lower case i want the program to convert it to upper case is it possible doing it, only using the #include <conio.h> ??
Thanks
i am working on a program , it ask for a character and it gives an error if its a number
Now the next thing i want to do is if we give a character in lower case i want the program to convert it to upper case is it possible doing it, only using the #include <conio.h> ??
Thanks
#include <stdio.h>
#include <conio.h>
int main (void)
{
int key;
printf ( "give a key ");
key = getch ();
if (key >= '0' && key <= '9')
printf ("\n\nError the key was not a character\n\n hit enter to close the program");
if (key >= 'a' && key <= 'z')
printf ("\n\nthe key was %c ",key);
getchar();
}
string EventName;
EventName = txtEventName.Text;
EventName.ToUpper();
txtEventName.Text = EventName;
EventName = txtEventName.Text;
EventName.ToUpper();
txtEventName.Text = EventName;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks
yes, it should be possible,
use printf ("\n\nupper case of the the key was %c ",key-32);
and this will give you the upper case.
use printf ("\n\nupper case of the the key was %c ",key-32);
and this will give you the upper case.
ah, Zoppo has already given the answer. ! :)
The problem with doing it that way is it relies on the underlying character encoding being of a format where this will work and there is nothing to say this is the case. The toupper function is a standard C function that is guaranteed to correctly convert to upper case given the correct locale (if you use the C++ version).
http://www.cplusplus.com/reference/clibrary/cctype/toupper/
You will need to enumerate through the string and uppercase each char.