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()

Share this Tutorial / Exercise on : Facebook and Twitter

C Programming: Tips of the Day

What's an object file in C?

An object file is the real output from the compilation phase. It's mostly machine code, but has info that allows a linker to see what symbols are in it as well as symbols it requires in order to work. (For reference, "symbols" are basically names of global objects, functions, etc.)

A linker takes all these object files and combines them to form one executable (assuming that it can, i.e.: that there aren't any duplicate or undefined symbols). A lot of compilers will do this for you (read: they run the linker on their own) if you don't tell them to "just compile" using command-line options. (-c is a common "just compile; don't link" option.)

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