| | |
Capitalizing all characters of a string
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
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.
you can make it a function:
or perhaps a more "easy to understand" bit of inline code:
try to understand exactly what is being done in either example
c Syntax (Toggle Plain Text)
void strToUppercase(char * myString) { while(*myString) *myString = toupper(*myString++) }
or perhaps a more "easy to understand" bit of inline code:
c Syntax (Toggle Plain Text)
char myString[128]; strcpy(myString,"the quick brown fox jumped over the lazy dogs"); for(a = 0; a<strlen(myString); a++) { if (myString[a] >= 'a' && myString[a] <= 'z') myString[a] -= 0x20; }
try to understand exactly what is being done in either example
![]() |
Similar Threads
Other Threads in the C Forum
- Previous Thread: need help with c
- Next Thread: simple batch
| Thread Tools | Search this Thread |
adobe ansi api array arrays asterisks binarysearch calculate centimeter char convert copyimagefile copypdffile cprogramme creafecopyofanytypeoffileinc createcopyoffile csyntax directory dynamic fflush file fork forloop frequency getlasterror givemetehcodez graphics gtkgcurlcompiling hacking hardware highest homework i/o inches incrementoperators infiniteloop initialization interest kernel km linked linkedlist linux linuxsegmentationfault list lists locate logical_drives match matrix microsoft motherboard multi mysql number open opendocumentformat opensource owf pattern pdf performance pointer pointers posix power problem probleminc program programming pyramidusingturboccodes radix read recursion recv repetition research scanf scheduling scripting segmentationfault send sequential shape socketprograming stack standard string strings structures systemcall testautomation turboc unix user variable voidmain() wab win32api windows.h






