CCL Home Page
Up Directory CCL gstring
#include "utility.h"

int gstring(prompt,null_ok,response)
/*============================================================================*/
/* PURPOSE: GET A STRING FROM THE USER.
/* INPUTS:
/*	PROMPT		PROMPT STRING TO BE DISPLAYED FOR USER.
/*	NULL_OK		TRUE/FALSE IF NULL ENTRY IS VALID.
/* OUTPUTS:
/*	RESPONSE	CHARACTER STRING TYPED IN BY USER.
/*	FUNCTION VALUE	STATUS OF USER RESPONSE (AS IN UTILITY.H).
/* WRITTEN: M.V.GRIESHABER
/* LAST MODIFICATION: 11 JUNE 1991 MVG
*/
   char prompt[];
   int null_ok;
   char response[];
   {
   char candidate[100];

   while(TRUE)
      {
      if (strlen(prompt)>0) printf("%s: ",prompt);
      gets(candidate);

      if (strlen(candidate)==0)
         {
         if (null_ok) return(NULL_ENTRY);
         else fprintf(stderr,"Error: Invalid response.\n\n");
         }
      else if (candidate[0]==ABORT_CHARACTER) return(ABORT_ENTRY);
      else
         {
         strcpy(response,candidate);
         return(VALID_ENTRY);
         }
      }
   }
Modified: Fri Feb 11 17:00:00 1994 GMT
Page accessed 8137 times since Sat Apr 17 21:58:57 1999 GMT