Punteros = ¡Diversión!

Marzo 12, 2008

Invirtiendo texto con punteros.

#include <stdio.h>

main( ) {
      char texto[80];
      char *p;
      int c,i;
      p = texto;
      printf("Introduce: ");
      gets(texto);
      while(*p != '') {
               c++;
               p++;
      }
      p = texto;
      for(i = 0; i <= c; i++) printf("%c",*(p+(c-i)));
      getchar();
      getchar();
}

Nótese la ironía ;) .

Escribe un comentario