Last active
November 7, 2016 19:21
-
-
Save salmanwahed/c01e100536d10181461a631741e31e57 to your computer and use it in GitHub Desktop.
Reversing a string.
This file contains hidden or 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> | |
# define SWAP(a, b) {char tmp; tmp=a; a=b; b=tmp;} | |
int main(){ | |
char str[80]; | |
int len, i; | |
scanf("%[^\n]*c", str); | |
len = strlen(str); | |
for (int i=0; i<(len/2); i++){ | |
SWAP(str[i], str[len-(i+1)]); | |
// printf("Pass %d: %s\n", i+1, str); | |
} | |
printf("%s\n", str); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment