Contents

Description

The puts() function writes the string at s, followed by a newline, to the standard output stream.

Return value

The puts() function returns a nonnegative integer if successful, or EOF if unsuccessful.

Prototype

Declared in stdio.h

The C89/C99 prototype is:

int puts(const char *s);

Implementation

In standard C, this can be implemented as:

#include <stdio.h>
int puts(const char *s)
{
    while(*s)
    {
      if(putchar(*s++) == EOF) return EOF;
    }
    if(putchar('\n') == EOF) return EOF;
    return 0;
}

Compilable unit, portable C90 in implementation namespace; public domain; past reviewers: none; current reviews: none

References

The C Standard, 7.19.7.10 (C99 numbering)

Personal tools
Tidy_icons
not logged in