[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 Base Operating System and Extensions Technical Reference, Volume 1

puts or fputs Subroutine

Purpose

Writes a string to a stream.

Library

Standard I/O Library (libc.a)

Syntax

#include  <stdio.h>

int   puts   (String)
const char   *String;

int   fputs  (String, Stream)
const char   *String;
FILE         *Stream;

Description

The puts subroutine writes the string pointed to by the String parameter to the standard output stream, stdout, and appends a new-line character to the output.

The fputs subroutine writes the null-terminated string pointed to by the String parameter to the output stream specified by the Stream parameter. The fputs subroutine does not append a new-line character.

Neither subroutine writes the terminating null character.

After the fputwc, putwc, fputc, fputs, puts, or putw subroutine runs successfully, and before the next successful completion of a call either to the fflush or fclose subroutine on the same stream or a call to the exit or abort subroutine, the st_ctime and st_mtime fields of the file are marked for update.

Parameters

String Points to a string to be written to output.
Stream Points to the FILE structure of an open file.

Return Values

Upon successful completion, the puts and fputs subroutines return the number of characters written. Otherwise, both subroutines return EOF, set an error indicator for the stream and set the errno global variable to indicate the error. This happens if the routines try to write to a file that has not been opened for writing.

Error Codes

If the puts or fputs subroutine is unsuccessful because the output stream specified by the Stream parameter is unbuffered or the buffer needs to be flushed, it returns one or more of the following error codes:

EAGAIN Indicates that the O_NONBLOCK flag is set for the file descriptor specified by the Stream parameter and the process would be delayed in the write operation.
EBADF Indicates that the file descriptor specified by the Stream parameter is not a valid file descriptor open for writing.
EFBIG Indicates that an attempt was made to write to a file that exceeds the process' file size limit or the systemwide maximum file size.
EINTR Indicates that the write operation was terminated due to receipt of a signal and no data was transferred.
Note: Depending upon which library routine the application binds to, this subroutine may return EINTR. Refer to the signal subroutine regarding the SA_RESTART bit.
EIO Indicates that the process is a member of a background process group attempting to perform a write to its controlling terminal, the TOSTOP flag is set, the process is neither ignoring or blocking the SIGTTOU signal, and the process group of the process has no parent process.
ENOSPC Indicates that there was no free space remaining on the device containing the file specified by the Stream parameter.
EPIPE Indicates that an attempt is made to write to a pipe or first-in-first-out (FIFO) that is not open for reading by any process. A SIGPIPE signal will also be sent to the process.
ENOMEM Indicates that insufficient storage space is available.
ENXIO Indicates that a request was made of a nonexistent device, or the request was outside the capabilities of the device.

Implementation Specifics

These subroutines are part of Base Operating System (BOS) Runtime.

Related Information

The fopen, freopen, or fdopen subroutine, fread, or fwrite subroutine, gets or fgets subroutine, getws or fgetws subroutine, printf, fprintf, and sprintf subroutine, putc, putchar, fputc, or putw subroutine, putwc, putwchar, or fputwc subroutine, putws or fputws subroutine.

The feof, ferror, clearerr, or fileno macros.

List of String Manipulation Services.

Subroutines Overview in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs.


[ Previous | Next | Contents | Glossary | Home | Search ]