home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / diskutil / fdf / elib / askuser.c next >
C/C++ Source or Header  |  1993-08-05  |  499b  |  44 lines

  1. #include <stdio.h>
  2.  
  3.  
  4.  
  5. /*
  6.  *    ask_user()
  7.  *
  8.  *    Input:
  9.  *    Output:
  10.  *    Comments:
  11.  */
  12.  
  13. int ask_user(char *buf)
  14. {
  15.     int done = 0;
  16.     char ans[10];
  17.     int retval;
  18.  
  19.     while(!done){
  20.         fprintf(stdout, "%s", buf);
  21.         if (gets(ans) != NULL){
  22.             switch(*ans){
  23.                 case 'n':
  24.                 case 'N':
  25.                     retval = 0;
  26.                     done = 1;
  27.                     break;
  28.                 case 'y':
  29.                 case 'Y':
  30.                     retval = 1;
  31.                     done = 1;
  32.                     break;
  33.                 case 'q':
  34.                 case 'Q':
  35.                     exit(0);
  36.                 default:
  37.                     break;
  38.             }
  39.         } else
  40.             exit(-1);
  41.     }
  42.     return(retval);
  43. }
  44.