Skip to content

Instantly share code, notes, and snippets.

@arantesxyz
Created April 17, 2020 18:35
Show Gist options
  • Select an option

  • Save arantesxyz/fbe66716dc1ff69b6a5bbc501548db00 to your computer and use it in GitHub Desktop.

Select an option

Save arantesxyz/fbe66716dc1ff69b6a5bbc501548db00 to your computer and use it in GitHub Desktop.
Reverse string c
#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