Advertisement Remove all ads

Explain Gets() and Puts() Functions of C Language. Comment on Their Parameters and Return Values. - Structured Programming Approach

Answer in Brief

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

Advertisement Remove all ads

Solution

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 newline character.

3. The newline 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.

Concept: Function
  Is there an error in this question or solution?
Advertisement Remove all ads

APPEARS IN

Advertisement Remove all ads
Advertisement Remove all ads
Share
Notifications

View all notifications


      Forgot password?
View in app×