Home Technical Technical Converting a string to upper case in C Language

Latest Comments

Bookmark this!!!

Converting a string to upper case in C Language PDF Print E-mail
Tweet me!
User Rating: / 0
PoorBest 
Technical - Technical
Written by Karthikeyan NG   
Sunday, 27 September 2009 19:43

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


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
}


Comments (0)
Write comment
Your Contact Details:
Comment:
[b] [i] [u] [url] [quote] [code] [img]   
:angry::0:confused::cheer:B):evil::silly::dry::lol::kiss::D:pinch:
:(:shock::X:side::):P:unsure::woohoo::huh::whistle:;):S
:!::?::idea::arrow:
Security
Please input the anti-spam code that you can read in the image.
 
Copyright © 2010 Karthikeyan NG. All Rights Reserved.
 


I am Karthikeyan NG, working as a software programmer in Hyderabad,India. Exploring new technologies, Bike riding, PC Gaming, Reading Novels, Blogging, Writing thamizh poems are my hobbies.


Who's Online

We have 1 guest online

Follow @ Twitter

Twitter / intrepidkarthi

My Visitors

mod_vvisit_countermod_vvisit_countermod_vvisit_countermod_vvisit_countermod_vvisit_counter
mod_vvisit_counterToday211
mod_vvisit_counterAll days4326

We have: 1 guests online
Your IP: 38.107.191.86
 , 
Today: Mar 15, 2010