Advertisement
Holey_yan

20140527_KUAS_VisualC++_Classwork_0514_Question_2_Answer

May 27th, 2014
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. /***********************************************/
  2. /** 20140527 Classwork_0514 Question 2 Answer **/
  3. /** Maker  : Yan                              **/
  4. /** E-Mail : ssas1115577@gmail.com            **/
  5. /** Date   : 2014/05/27 pm.04:12              **/
  6. /***********************************************/
  7.  
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <string.h>
  11.  
  12. void main()
  13. {
  14.     while(1)
  15.     {
  16.         printf("Please input a string: ");
  17.         char input[20] = {EOF};
  18.         scanf("%s", input);
  19.         if((input[0] == '0') && (input[1] == '\0'))
  20.         {
  21.             printf("See You Next Time! Bye Bye!\n");
  22.             system("pause");
  23.             exit(1);
  24.         }
  25.         else
  26.         {
  27.             char output[20] = {EOF};
  28.             int counter = 0;
  29.             for(int i = strlen(input) - 1; i >= 0; i--)
  30.             {
  31.                 output[counter] = input[i];
  32.                 counter++;
  33.             }
  34.  
  35.             printf("The inverse string is: %s.\n", output);
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement