Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

C Library Function - puts()

C Library Function - puts()

C Standard Library - <stdio.h> C Standard Library -

Description

C library function *int puts(const char str) Writes a string to the 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)

Parameters

Return Value

On success, the function returns a non-negative value, the length of the string (including the trailing \0), or EOF if an error occurs.

Example

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

Example

#include

#include

int

main

(

)

{

   

char

str1

[

15

]

;

   

char

str2

[

15

]

;

   

strcpy

(

str1

,

"RUNOOB1"

)

;

   

strcpy

(

str2

,

"RUNOOB2"

)

;

   

puts

(

str1

)

;

   

puts

(

str2

)

;

   

   

return

(

0

)

;

}

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



RUNOOB1

RUNOOB2

C Standard Library - <stdio.h> C Standard Library -