Chapter18ex2.c 369 B

12345678910111213141516171819202122232425262728293031
  1. #include <stdio.h>
  2. #include <string.h>
  3. main()
  4. {
  5. int i;
  6. char msg[25];
  7. printf("Type up to 25 character and then press Enter...\n");
  8. for (i = 0; i < 25; i++)
  9. {
  10. msg[i] = getchar();
  11. if (msg[i] == '\n')
  12. {
  13. i--;
  14. break;
  15. }
  16. }
  17. putchar('\n');
  18. for (; i >=0; i--)
  19. {
  20. putchar(msg[i]);
  21. }
  22. putchar('\n');
  23. return(0);
  24. }