Created
February 10, 2019 01:52
-
-
Save Adobe-Android/11bc4ad3966390fe81bb75e027932fec to your computer and use it in GitHub Desktop.
C string reversal
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
int main() | |
{ | |
char s[20], r[20]; | |
int begin, end, count = 0; | |
printf("Input a string\n"); | |
scanf("%s", s); | |
// Calculating string length | |
while (s[count] != '\0') | |
count++; | |
end = count - 1; | |
for (begin = 0; begin < count; begin++) { | |
r[begin] = s[end]; | |
end--; | |
} | |
r[begin] = '\0'; | |
printf("%s\n", r); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment