0

Hi..

I want to write a C++ program which reads a text from the user
and change any uppercase letter to an lowercase letter and assign them to an stack??

please help..

5
Contributors
5
Replies
6
Views
6 Years
Discussion Span
Last Post by Narue
0

Well, you can try this:

1) Check if it is an Uppercase letter.(Using the ASCII value)

2) If it is, add 32 to it.(convert it to lower case)

Ascii Table

0

Is there a toUpper or toLower in C/++ ?

The ctype.h library has functions

int toupper(int c);
int tolower(int c);

0

Hi..

look at this code:

if( char >= 65 || char <= 90 )
   char = static_cast< char >( char + 32 );
cout<<char;

after reading the char if its uppercase add to it 32 and then assign it to char.

1

char is a keyword, you can't use it for a variable name. And don't use magic numbers. If you must rely on ASCII (std::tolower exists for a reason), at least use character literals:

if (c >= 'A' && c <= 'Z')
    c += 'a' - 'A';
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.