0

anyone can tell me what this line does?

return ('A' + c1 - 'a');

its in this function..

char LToU(char c1) 
{ 
if ((c1 >= 'a') && (c1 <= 'z')) 
return ('A' + c1 - 'a'); 
return(c1); 
}

Edited by Master Mascus: n/a

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by D33wakar
0

anyone can tell me what this line does?

clearly, it's returning the uppercase of the character given to the function.The first return statement only works if the condition cl>='a'(i.e.97 in decimal) AND cl<='z'(i.e 122 in decimal).If it does so then the second return statement is not executed, but if it does not then the second return statement is executed and returns whatever character was given to the function.So if you give any upper case characters or symbols then they will be returned unchanged.But if you give any lower case characters, let's suppose 'b'
then this line

return ('A' + c1 - 'a');

looks like this

return (65+98-97);
//or
return(0x41+0x62-0x61);

this ascii table might help you further.
have a lovely day!

Edited by D33wakar: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.