cgets

Gets a string of characters directly from the current screen and stores the string and its length in an array

Local Servers:blocking
Remote Servers:N/A
Classification:Other
Service:Device I/O

Syntax

  #include <nwconio.h>  
   
  char *cgets  (  
     char   *buf);
  

Parameters

buf

(IN) Points to the array.

Return Values

cgets returns a pointer to the start of the string, which is at buf [2].

Remarks

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 carriage-return/line-feed combination is read, or until the specified number of characters is read. The string is stored in the array starting at buf [2]. The carriage-return/line-feed combination, if read, is replaced by a null character. The actual length of the string read is placed in buf [1].

See Also

getch, getche, gets (Single and Intra-File Services)

Example

  #include <nwconio.h>  
  #include <stdio.h>  
   
  main ()  
  {  
     char buffer[82];  
     buffer[0]=80;  
     cgets (buffer );  
     cprintf ("%s\r\n", &buffer[2] );  
  }