HP C/iX Library Reference Manual (30026-90004)
Chapter 5 281
HP C/iX Library Function Descriptions
puts
puts
Writes a string to the standard output stream stdout.
Syntax
#include <stdio.h>
int puts (const char *
s
);
Parameters
s
A pointer to a character array containing the string to be written to
stdout. The character array must be terminated with a null character.
Return Values
≥0 Success.
EOF An error occurred.
Description
The puts function writes the string from a character array pointed to by
s
to the standard
output stream stdout. The string is terminated by a null character in the array, which
puts() replaces with a new line in the output.
Examples
The following example uses gets() and puts():
#include <stdio.h>
main()
{
char line[80], *gets();
while((gets(line)) != NULL)
puts(line);
}
To terminate this program, generate an end of file on stdin. Using string comparison and
string length functions, you can write a termination condition for this program.
See Also
fputc(), fwrite(), gets(), putc(), putchar(), ANSI C 4.9.7.10, POSIX.1 8.1