Created
April 6, 2014 19:14
-
-
Save marcoscastro/10010306 to your computer and use it in GitHub Desktop.
inverte uma string
This file contains 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> | |
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