0
4.6kviews
Explain gets() and puts() functions of C language. Comment on their parameters and return values.

Subject : Structured Programming Approach

Title : Fundamentals Of C-Programming

Marks : 5M

1 Answer
0
317views

gets():

1.gets() function is used to scan a line of text from a standard input device.

2.This function will be terminated by a new line character.

3.The new line character won’t be included as part of the string. The string may include white space characters.

Syntax :char *gets(char *s);

4.This function is declared in the header file stdio.h.

5.It takes a single argument. The argument must be a data item representing a string. On successful completion, shall return a pointer to string s.

puts():

The C library function int puts(const char *str) writes a string to stdout up to but not including the null character.A newline character is appended to the output.

Example: int puts(char const*str)

Parameters: str-this is the C string to be written

Return value: If successful, non-negative value is returned. On error, the function returns EOF.

Please log in to add an answer.