Easy Tutorial
❮ C Nested If C Command Line Arguments ❯

C Library Function - puts()

C Standard Library - <stdio.h>

Description

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

Declaration

Here is the declaration for the puts() function.

int puts(const char *str)

Parameters

Return Value

On success, the function returns a non-negative value equal to the length of the string (including the terminating \0), and on error it returns EOF.

Example

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

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

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

   strcpy(str1, "tutorialpro1");
   strcpy(str2, "tutorialpro2");

   puts(str1);
   puts(str2);

   return(0);
}

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

tutorialpro1
tutorialpro2

C Standard Library - <stdio.h>

❮ C Nested If C Command Line Arguments ❯