Facebook
From Lisa, 1 Year ago, written in C.
Embed
Download Paste or View Raw
Hits: 325
  1. #include <stdio.h>
  2.  
  3. void structsList()
  4. {
  5. typedef struct
  6.     {
  7.         char player_input_A;
  8.         char player_input_B;
  9.     }player_options;
  10.  
  11. }
  12.  
  13. /////////////////////////////////////////////////////////////////////////
  14. char player_input()
  15. {
  16.     structsList();
  17.  
  18.     char player_choice;
  19.     scanf("%c",&player_choice);
  20.  
  21.   switch(player_choice)
  22.   {
  23.     case 'A':
  24.       printf("GREAT! you have chosen A");
  25.       return player_choice;
  26.       break;
  27.  
  28.     case 'B':
  29.       printf("GREAT! you have chosen B");
  30.       return player_choice;
  31.       break;
  32.     case '\n':
  33.     case EOF :
  34.         return -1;
  35.     default:
  36.       printf("Error, Try again\n");
  37.       break;
  38.  
  39.   }
  40. }
  41.  
  42. /////////////////////////////////////////////////////////////////////////
  43. int main()
  44. {
  45.   puts("Titel\n");
  46.   puts("TEXT\n");
  47.   puts("Choose A for: \n");
  48.   puts("Choose B for: \n");
  49.   printf("Your choice: \n");
  50.   int count = -1;
  51.   while (count < 1)
  52.   {
  53.       if (count >= 1)
  54.       {
  55.           count = 1;
  56.       }
  57.       else
  58.           count = player_input();
  59.   }
  60.  
  61. }
  62.