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►
────────────────────────────────────────────────────────────────────────────
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──line-feed 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]>.
All DOS editing keys are active when you call cgets. Therefore,
pressing F3 repeats the last entry.
Return Value
The cgets function returns a pointer to the start of the string,
which is at <buffer[2]>. There is no error return.
-♦-