C Language and Libraries Help (clang.hlp) (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
_cgets
 Summary Example                         Up Contents Index Back
─────Run-Time Library───────────────────────────────────────────────────────
 
     The _cgets function reads a string of characters directly from the
     console and stores the string and its length in the location
     pointed to by <buffer>.
 
     The <buffer> argument must be a pointer to a character array. The
     first element of the array, <buffer[0]>, must contain the maximum
     length (in characters) of the string to be read. The array must
     have enough elements to hold the string, a terminating null
     character (\0), and two additional bytes.
 
     The _cgets function continues to read characters until a carriage-
     return─linefeed combination (CR-LF) is read, or the specified
     number of characters is read. The string is stored starting at
     <buffer[2]>. If a CR-LF combination is read, it is replaced with
     a null character (\0) before being stored. The _cgets function
     then stores the actual length of the string in the second array
     element, <buffer[1]>.
 
     The _cgets function allows editing of the entry with the same keys
     available from the DOS command line. Use gets if you do not want
     editing to be available.
 
     Return Value
 
     The _cgets function returns a pointer to the start of the string,
     which is at <buffer[2]>. There is no error return.
                                    -♦-