Using C for evil
Have you ever encountered people on the web who TyPe LiKe ThIs?. Unfortunately, I think we all have.
Well I was bored with C, so I put together this evil function.
#define UCASE 1
#define LCASE 0
void altCaps(const char *str, char *t) {
int state = UCASE;
while (*str) {
char c = *str++;
if (state == UCASE) {
if (c >= 'a' && c <= 'z') {
c = 'A' + (c - 'a');
}
state = LCASE;
} else {
if (c >= 'A' && c <= 'Z') {
c = 'a' + (c - 'A');
}
state = UCASE;
}
*t++ = c;
}
*t = '\0';
}Pure evil! For fun, take your friend's assignments and run them through this function :)
Comments
No comments yet.
Leave a Comment
Note: Your comment may require approval before it is posted to the site.