[Previous] [Contents] [Next]

puts()

Write a string to stdout

Synopsis:

#include <stdio.h>

int puts( const char *buf );

Library:

libc

Description:

The puts() function writes the character string pointed to by buf to the stdout stream, and appends a newline character to the output. The terminating NUL character of buf isn't written.

Returns:

A nonnegative value for success, or EOF if an error occurs.

Errors:

If an error occurs, errno is set to indicate the type of error.

Examples:

#include <stdio.h>
#include <stdlib.h>

int main( void )
{
    FILE *fp;
    char buffer[80];

    fp = freopen( "file", "r", stdin );
    while( gets( buffer ) != NULL ) {
        puts( buffer );
    }
    fclose( fp );
    
    return EXIT_SUCCESS;
}

Classification:

ANSI

Safety:
Cancellation point Yes
Interrupt handler No
Signal handler No
Thread Yes

See also:

errno, fputs(), putc()


[Previous] [Contents] [Next]