Guest User

Untitled

a guest
Jun 19th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. /*
  2.  * Código presentado por Elinv.
  3.  * Dar vuelta un texto al reves por función.
  4.  * CODE BLOCK 10.05 - Console Application
  5.  */
  6. //Librerías
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <string.h>
  10. #include <ctype.h>
  11.  
  12. void alreves(char texto[])
  13. {
  14.      int largo=strlen(texto);
  15.      char t;
  16.      int i, j;
  17.      for(i=(--largo), j=0; i>largo/2; i--, j++)
  18.      {
  19.           // exchange elements
  20.           t=texto[i];
  21.           texto[i]=texto[j];
  22.           texto[j]=t;
  23.      }
  24. }
  25.  
  26. // main program
  27. int main ()
  28. {
  29.     char buffer[]= "hola espacio ya no estas";
  30.  
  31.     alreves(buffer);
  32.     puts(buffer);
  33. }
Add Comment
Please, Sign In to add comment