gets

Reads a line from the standard input (stdin).

Format

#include  <stdio.h>

char *gets  (char *str);
Function Variants This function also has variants named _gets32 and _gets64 for use with 32-bit and 64-bit pointer sizes, respectively. See Section 1.8 for more information on using pointer-size-specific functions.

Argument

str
A pointer to a character string that is large enough to hold the information fetched from stdin.

Description

The new-line character (\n) that ends the line is replaced by the function with an ASCII null character (\0).

When stdin is opened in record mode, gets treats the end of a record the same as a new-line character and, therefore, reads up to and including a new-line character or to the end of the record.

Return Values
A pointer to the str argument. 
NULL  Indicates that an error has occurred or that the end-of-file was encountered before a new-line character was encountered. The contents of str are undefined if a read error occurs. 


Previous Page | Next Page | Table of Contents | Index