Created
April 17, 2020 18:35
-
-
Save arantesxyz/fbe66716dc1ff69b6a5bbc501548db00 to your computer and use it in GitHub Desktop.
Reverse string c
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> | |
| int main() | |
| { | |
| char s[50], r[50]; | |
| int c = 0; | |
| int begin; | |
| int end; | |
| printf("Digite algo:\n"); | |
| gets(s); | |
| // Calcula o tamanho da string | |
| while (s[c] != '\0') | |
| c++; | |
| end = c - 1; | |
| for (begin = 0; begin < c; 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