C puts() function

C library function - puts()

The puts() function is used to write specified string (plus a newline), to the standard output stream. The ending null character is not written.


int puts(const char *str)


Name Description Required /Optional
str This is the string to be written. Required

Return value

  • Upon successful completion, puts() shall return a non-negative number.
  • Otherwise, it shall return EOF, shall set an error indicator for the stream, and errno shall be set to indicate the error.

Example: puts() function

#include <stdio.h>
int main() 
    const char *text = "C Programming.";
    return 0;


C Programming.

Difference from printf()

  • The puts() function prints a newline after the text supplied.
  • The puts() function prints the string as it is (% codes are not processed).

C Programming Code Editor:

Previous C Programming: C putchar()
Next C Programming: C perror()

Follow us on Facebook and Twitter for latest update.

C Programming: Tips of the Day

What is the static function in C ?

Making a function static hides it from other translation units, which helps provide encapsulation.


int f1(int);        /* prototype */
static int f2(int); /* prototype */

int f1(int foo) {
    return f2(foo); /* ok, f2 is in the same translation unit */
                    /* (basically same .c file) as f1         */

int f2(int foo) {
    return 42 + foo;


int f1(int); /* prototype */
int f2(int); /* prototype */

int main(void) {
    f1(10); /* ok, f1 is visible to the linker */
    f2(12); /* nope, f2 is not visible to the linker */
    return 0;

Ref : https://bit.ly/3CI9ebJ

We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook