Function puts () in C

The function int puts (const char * str) in the standard C library writes a str string to stdout (not writing null characters). A newline character (new line) is appended to the output.

The function int puts (const char * str) in the standard C library writes a str string to stdout (not writing null characters). A newline character (new line) is appended to the output.

Declaring the function puts () in C

Here is the declaration for function puts () in C:

 int puts ( const char * str ) 

Parameters

str - This is the string to be written.

Returns the value

If successful, this function returns a non-negative value. If there is an error, the function returns EOF.

For example

Program C then illustrates the usage of functions puts () in C:

 #include #include int main () { char str1 [ 15 ]; char str2 [ 15 ]; strcpy ( str1 , "QTMteam" ); strcpy ( str2 , "xinchaocacban" ); puts ( str1 ); puts ( str2 ); return ( 0 ); } 

Compile and run the above C program to see the results.

According to Tutorialspoint

Previous lesson: putchar () function in C

Next lesson: Function ungetc () in C

Update 25 May 2019
Category

System

Mac OS X

Hardware

Game

Tech info

Technology

Science

Life

Application

Electric

Program

Mobile