Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <malloc.h>
- char *invert(char *s)
- {
- int a=0, i;
- while(*s != '\0')
- {
- a++;
- s++;
- }
- char *x = (char *)malloc(sizeof(char)*a);
- for(i=0; i<a; i++)
- *(x+i) = *(s-i-1);
- *(x+i) = '\0';
- return x;
- }
- void main()
- {
- char *a = (char *)malloc(sizeof(char)*20), *b;
- scanf("%s", a);
- b = invert(a);
- printf("%s", b);
- }
Advertisement
Add Comment
Please, Sign In to add comment