#include #include void UserPrompt(char *message, char *answer,int NumChars) { /* Prompt user with message and put an answer of no more than NumChars */ /* in the object pointed to by answer (an int or a char string) */ char *TextInLine, *buffer, *ptr ; int row, col ; row = wherey() ; col = wherex() ; /* save cursor position */ buffer = (char *) calloc(NumChars+2,sizeof(char)); TextInLine = (char *) malloc(161); gettext(1,25,80,25,TextInLine); gotoxy(1,25) ; clreol() ; /* clear last line */ cputs(message) ; /* write prompt */ *buffer = NumChars ; ptr = cgets(buffer) ; strcpy(answer,ptr) ; /* answer is a pointer to a string */ puttext(1,25,80,25,TextInLine) ; /* restore last line */ gotoxy(col,row) ; /* restore cursor position */ free(buffer) ; free(TextInLine) ; return ; }