converting to upper case

Hi,i am unsure how to write a function which modifies the content of the 1D character array and puts all of the letter it contains into uppercase. the following are the letters which i am trying to convert.

char text[MAX+1] = {'T', 'e', 's', 't', 'e', 'r', EOT};


the output to this should look like T E S T E R EOT
thanks for reading and hopefully you can help me out :D
you could look at an asci table

There you'll find values for all kind of characters including A and a (I think a has a higher value)

Then if the character is under a specific value (var < a) then you add a certain value (difference needed from A to a)

sth like this:

Note: Not Tested!
1
2
3
4
5
for(int i = 0; text[i] != 0; ++i)
{
if(text[i] < 'a') 
    a += ('a' - 'A');
}
Last edited on
Alternately, as a better option, you could have a look at something like http://www.cplusplus.com/reference/cctype/toupper/
Topic archived. No new replies allowed.