C – Gets 2017-06-12T10:32:40+00:00

gets

It is used to scan a  line of text from a standard input device. The gets() function will be terminated by a newline character. The newline character won’t be included as part of the string. The string may include white space characters.

Syntax :      char *gets(char *s);

gets() function is declared in the header file stdio.h. It takes a single argument. The argument must be a data item representing a string. On successful completion, gets() shall return a pointer to string s.

The usage of gets() is illustrated in the following program.

Output :

Enter a string

Good morning

Given string is Good morning

Prev Next