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
Vlad
Posted on Wednesday, 28th December 2011 @ 1:44pm.Forgot about toupper/tolower?
sripada
Posted on Thursday, 14th July 2011 @ 4:23pm.nice!!!!!!
Keylogger software
Posted on Friday, 27th May 2011 @ 5:23pm.Thanks for providing such valuable details, it will be very useful.
Anand
Posted on Tuesday, 12th April 2011 @ 2:43pm.What happen if i run this!! :)
Leave a Comment
Note: Your comment may require approval before it is posted to the site.