Web Development for 2012

Alexander Dickson - Web Developer covering PHP, jQuery / Javascript, XHTML, CSS, more

Using C for evil

Published on Thursday, 21st October 2010.

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

Comment Details

Your email will never be displayed. If you have a gravatar, it will be displayed.

Note: Your comment may require approval before it is posted to the site.

Stack Overflow Profile

view full profile »

About

I'm a web developer from the Sunshine Coast, Australia. more »