All I need to know is how to capitalize all of the characters of a string. What kinds of functions would I use?

Recommended Answers

All 2 Replies

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.

you can make it a function:

void strToUppercase(char * myString)
{
   while(*myString)
      *myString = toupper(*myString++)
}

or perhaps a more "easy to understand" bit of inline code:

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.