FranciscoSoccol

Lista 09 - Exercicio 07 (uma string)

Sep 10th, 2013
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.51 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<string.h>
  4.  
  5. #define MAX 100
  6.  
  7. void inverteString(char *s);
  8.  
  9. int main( int argc, char *argv[])
  10. {
  11.     int i;
  12.     char nome[MAX];
  13.     strcpy(nome,argv[1]);
  14.     inverteString(nome);
  15.     printf("%s",nome);
  16.     return 0;
  17. }
  18.  
  19. void inverteString(char *s)
  20. {
  21.     int i;
  22.     char *aux;
  23.     aux=s;
  24.     char *novaString =(char*)malloc(sizeof(strlen(aux)));
  25.     for(i=0;i<strlen(aux)+1;i++){
  26.         novaString[strlen(aux)-(i+1)]=aux[i];}
  27.     strcpy(aux,novaString);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment