1 #include <msvcrt/conio.h>
2 #include <msvcrt/stdlib.h>
8 char *_cgets(char *string)
11 unsigned int maxlen_wanted;
15 * Be smart and check for NULL pointer.
16 * Don't know wether TURBOC does this.
20 maxlen_wanted = (unsigned int)((unsigned char)string[0]);
23 * Should the string be shorter maxlen_wanted including or excluding
24 * the trailing '\0' ? We don't take any risk.
26 while(len < maxlen_wanted-1)
30 * shold we check for backspace here?
31 * TURBOC does (just checked) but doesn't in cscanf (thats harder
32 * or even impossible). We do the same.
38 _cputs("\b \b"); /* go back, clear char on screen with space
41 sp[len] = '\0'; /* clear the character in the string */
51 /* special character ends input */
53 _ungetch(c); /* keep the char for later processing */
62 sp[maxlen_wanted-1] = '\0';
63 string[1] = (char)((unsigned char)len);