Latest web development tutorials

C library functions - puts ()

C standard library - <stdio.h> C standard library - <stdio.h>

description

C library functionsint puts (const char * str) Writes a string to the standard output stdout, until a null character, but not including the null character.Newline character is appended to the output.

statement

Here is () statement puts function.

int puts(const char *str)

parameter

  • str - which it is to be written in C string.

return value

If successful, the function returns a non-negative value if an error occurs returns EOF.

Examples

The following example demonstrates the puts () function is used.

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

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

   strcpy(str1, "w3cschool");
   strcpy(str2, "w3cbird");

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

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

w3cschool
w3cbird

C standard library - <stdio.h> C standard library - <stdio.h>