gets

Description

Gets a line from the stdin stream.

#include <stdio.h>

char *gets( char *buffer );

buffer Storage location for input string  

Remarks

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.

Return Value

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.

Compatibility

Standards:ANSI, UNIX

16-Bit:DOS, QWIN

32-Bit:DOS32X

See Also

fgets, fputs, puts

Example

/* 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 );

}

Output

Input a string: This is a string

The line entered was: This is a string