C library functions -puts()

C Standard Library - <stdio.h>

Description

C Library Functionsint puts(const char *str)Write a string to standard output stdout, up to but not including the null character. A newline character is appended to the output.

Declaration

The following is the declaration of the puts() function.

int puts(const char *str)

Parameter

  • str-- This is the C string to be written.

Return Value

If successful, this function returns a non-negative value as the string length (including the trailing\0), and returns EOF if an error occurs.

Example

The following example demonstrates the usage of the puts() function.

Example

#include <stdio.h>
#include <string.h>

int main()
{
   char str1[15];
   char str2[15];

   strcpy(str1, "EXAMPLE1");
   strcpy(str2, "EXAMPLE2");

   puts(str1);
   puts(str2);
   
   return(0);
}

Let us compile and run the above program, which will produce the following result:

EXAMPLE1
EXAMPLE2

C Standard Library - <stdio.h>

other extensions