Capitalizing all characters of a string

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Mar 2008
Posts: 6
Reputation: Gerritt is an unknown quantity at this point 
Solved Threads: 0
Gerritt Gerritt is offline Offline
Newbie Poster

Capitalizing all characters of a string

 
0
  #1
Mar 14th, 2008
All I need to know is how to capitalize all of the characters of a string. What kinds of functions would I use?
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,519
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1480
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Capitalizing all characters of a string

 
0
  #2
Mar 14th, 2008
you need a loop and the macro toupper(). For example of how to convert a single character to upper case please read the related thread that appeared immediately next to the one you created.
Last edited by Ancient Dragon; Mar 14th, 2008 at 11:54 pm.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 1,665
Reputation: jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of jephthah has much to be proud of 
Solved Threads: 123
jephthah's Avatar
jephthah jephthah is offline Offline
Posting Virtuoso

Re: Capitalizing all characters of a string

 
0
  #3
Mar 16th, 2008
you can make it a function:
  1. void strToUppercase(char * myString)
  2. {
  3. while(*myString)
  4. *myString = toupper(*myString++)
  5. }

or perhaps a more "easy to understand" bit of inline code:
  1. char myString[128];
  2.  
  3. strcpy(myString,"the quick brown fox jumped over the lazy dogs");
  4.  
  5. for(a = 0; a<strlen(myString); a++)
  6. {
  7. if (myString[a] >= 'a' && myString[a] <= 'z')
  8. myString[a] -= 0x20;
  9. }

try to understand exactly what is being done in either example
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC