Gets a line from the stdin stream.
#include <stdio.h>
char *gets( char *buffer );
buffer | Storage location for input string |
The gets function reads a line from the standard input stream stdin and stores it in buffer. The line consists of all characters up to and including the first newline character (\n). The gets function then replaces the newline character with a null character ('\0') before returning the line. In contrast, the fgets function retains the newline character.
If successful, the gets function returns its argument. A NULL pointer indicates an error or end-of-file condition. Use ferror or feof to determine which one has occurred.
Standards:ANSI, UNIX
16-Bit:DOS, QWIN
32-Bit:DOS32X
/* GETS.C */
#include <stdio.h>
void main( void )
{
char line[81];
printf( "Input a string: " );
gets( line );
printf( "The line entered was: %s\n", line );
}
Input a string: This is a string
The line entered was: This is a string