Write a string to stdout
#include <stdio.h> int puts( const char *buf );
libc
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.
A nonnegative value for success, or EOF if an error occurs.
If an error occurs, errno is set to indicate the type of error.
#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;
}
| Safety: | |
|---|---|
| Cancellation point | Yes |
| Interrupt handler | No |
| Signal handler | No |
| Thread | Yes |