write a character string to an output stream
#include <stdio.h> int fputs( const char *buf, FILE *fp );
The fputs() function writes the character string pointed to by buf to the output stream designated by fp. The terminating null character isn't written.
A nonnegative value (which is the number of characters written, including newlines), or EOF if an error occurs. When an error has occurred, errno indicates the type of error detected.
#include <stdio.h> void main() { FILE *fp_in, *fp_out; char buffer[80]; fp_in = fopen( "file", "r" ); fp_out = fopen( "outfile", "w" ); if( fp_in != NULL && fp_out != NULL) { while( fgets( buffer, 80, fp_in ) != NULL ) fputs( buffer, fp_out ); fclose( fp_in ); fclose( fp_out ); } }
ANSI
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | No |
Thread | Yes |
errno, ferror(), fopen(), fputc(), fputchar(), putc(), putchar(), puts()