get a string of characters directly from the console
#include <conio.h> char *cgets( char *buf );
The cgets() function gets a string of characters directly from the console, and stores the string and its length in the array pointed to by buf. The first element of the array, buf[0], must contain the maximum length in characters of the string to be read. The array must be big enough to hold the string, a terminating null character, and two additional bytes.
The cgets() function reads characters until a newline character is read, or until the specified number of characters is read. The string is stored in the array starting at buf[2]. The newline character, if read, is replaced by a null character. The actual length of the string read is placed in buf[1].
A pointer to the start of the string, which is at buf[2].
#include <conio.h> void main() { char buffer[82]; buffer[0] = 80; cgets( buffer ); cprintf( "%s\r\n", &buffer[2] ); }
WATCOM
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | Yes, but modifies errno |
Thread | Yes |
fgets(), getch(), getche(), gets()