By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,597 Members | 1,284 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,597 IT Pros & Developers. It's quick & easy.

Upper to lowercase function

P: 25
Hi everyone, I am required to write a standard C function to import the single character variable and return the lowercase version of the character

Expand|Select|Wrap|Line Numbers
  1. int upper_to_lower ( char singlecharacter )
  2. {
  3. if ( ( singlecharacter >= 'A' ) && ( singlecharacter <= 'Z' ) )
  4.            {
  5.            // returning the uppercase version here
  6.            }
  7. else
  8.           {
  9.           return singlecharacter;
  10.           }
  11.  
  12. }
  13.  
Could someone help me convert the uppercase to lowercase inside the if statement written above? Is there a routine in C library that converts the uppercase to lowercase character?

Thank you so much for the help
Nov 13 '06 #1
Share this Question
Share on Google+
2 Replies


Expert 100+
P: 1,510
Hi everyone, I am required to write a standard C function to import the single character variable and return the lowercase version of the character

Expand|Select|Wrap|Line Numbers
  1. int upper_to_lower ( char singlecharacter )
  2. {
  3. if ( ( singlecharacter >= 'A' ) && ( singlecharacter <= 'Z' ) )
  4.            {
  5.            // returning the uppercase version here
  6.            }
  7. else
  8.           {
  9.           return singlecharacter;
  10.           }
  11.  
  12. }
  13.  
Could someone help me convert the uppercase to lowercase inside the if statement written above? Is there a routine in C library that converts the uppercase to lowercase character?

Thank you so much for the help
have a look at the tolower() function in <ctype.h>, see
http://www.cprogramming.com/fod/tolower.html
Nov 13 '06 #2

P: 4
Hi everyone, I am required to write a standard C function to import the single character variable and return the lowercase version of the character

Expand|Select|Wrap|Line Numbers
  1. int upper_to_lower ( char singlecharacter )
  2. {
  3. if ( ( singlecharacter >= 'A' ) && ( singlecharacter <= 'Z' ) )
  4.            {
  5.            // returning the uppercase version here  //you'll need 
  6.            //   #include <string> in your program as header file
  7.                string temp = "";
  8.  
  9.                int size = singlecharacter.length();
  10.                for(int i = 1; i < size; i++)
  11.                     temp = temp + toupper(singlecharacter[i]);
  12.                return temp;
  13.            }
  14. else
  15.           {
  16.           return singlecharacter;
  17.           }
  18.  
  19. }
  20.  
Could someone help me convert the uppercase to lowercase inside the if statement written above? Is there a routine in C library that converts the uppercase to lowercase character?

Thank you so much for the help
I hope this help.
Nov 18 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.