Skip to content

Instantly share code, notes, and snippets.

@marcoscastro
Created April 6, 2014 19:14
Show Gist options
  • Save marcoscastro/10010306 to your computer and use it in GitHub Desktop.
Save marcoscastro/10010306 to your computer and use it in GitHub Desktop.
inverte uma string
#include <stdio.h>
#include <string.h>
void lerNome(char *nome)
{
printf("Digite um nome: ");
scanf("%s", nome);
}
void imprimeNomeInvertido(char *nome)
{
int tam = strlen(nome);
int i;
printf("\nNome invertido: ");
for(i = tam - 1; i >= 0; i--)
printf("%c", nome[i]);
}
int main(void) {
char nome[100];
lerNome(nome);
imprimeNomeInvertido(nome);
// a linha abaixo substitui o system("pause")
// descartável na maioria das IDE's
scanf("%*c");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment