Standard Library Functions in C

adplus-dvertising
gets() Function
Previous Home Next

Description

The C library function, The gets( ) function reads characters from stdin and places them into the character array pointed to by str.

Declaration

Following is the declaration for gets() function.

char *gets(char *str)

Parameters

str - Pointer to a block of memory (array of char) where the string read is copied as a C string.

Return Value

This function returns str on success, and NULL on error or when end of file occurs, while no characters have been read.

Example

#include<stdio.h>

void main()
{
char name[20];
printf("\nEnter the Name : ");
gets(name);
}

Output

Enter the Name :r4r.co.in
Previous Home Next