Converting a string to upper case

This function converts strings into upper case in C language. It is a simple one. I use ternary operator.

void UppCase(Char *str)
while(*str!=0)//traversing until end of atring

/* check whether the char is between ‘a’ and ‘z’. If it is subtract the ASCII value of ‘a’ and add ASCII value of ‘A’. Otherwise print the char as it is */

*str = (*str>=’a’ && *str <= ‘z’)?(*str-‘a’+’A’):*str;
str++;//increment pointer to next position

By intrepidkarthi

I am Karthikeyan, working as a software professional, interested in Travelling, Bike riding, PC Gaming, Reading Novels, Blogging, Writing thamizh poems.

Leave a Reply

Your email address will not be published.