Last active
November 29, 2015 02:09
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Toggles character case | |
* | |
* e.g in: 'b' -> out: 'B' | |
* in: 'B' -> out: 'b' | |
* in: '5' -> out: '5' | |
* | |
* @param c ascii character to be toggled | |
* @return toggled ascii character if alphabetical, | |
* otherwise intact value of c | |
*/ | |
int | |
toggle_case(int c) | |
{ | |
if(c >= 'A' && c <= 'Z') | |
return c + 'a' - 'A'; | |
else if(c >= 'a' && c <= 'z') | |
return c - ('a' - 'A'); | |
else | |
return c; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment