Created
January 26, 2011 14:25
-
-
Save kavu/796750 to your computer and use it in GitHub Desktop.
This file contains 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
#include <stdio.h> | |
#include <string.h> | |
#include <ctype.h> | |
static char buf[] = "the world helorow"; | |
static void revstr(char *start, char *end) { | |
register char temp; | |
while(start < end) { | |
temp = *start; | |
*start++ = *end; | |
*end-- = temp; | |
} | |
} | |
int main(int argc, char **argv) { | |
register char *end, *x, *y; | |
printf("Original string --- %s\n",buf); | |
end = &buf[strlen(buf)]; | |
revstr(buf,end-1); | |
printf ("Reversed --- %s\n",buf); | |
x = y = buf; | |
while(x++ < end) { | |
if(/* !isalnum(*x) || */ isspace(*x) || iscntrl(*x)) { | |
revstr(y,x-1); | |
y = x+1; | |
} | |
} | |
printf("Processed string --- %s\n",buf); | |
return(0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment