fputs

write a character string to an output stream

Synopsis:

#include <stdio.h>
int fputs( const char *buf, FILE *fp );

Description:

The fputs() function writes the character string pointed to by buf to the output stream designated by fp. The terminating null character is not written.

Returns:

The fputs() function returns EOF if an error occurs; otherwise it returns a non-negative value. When an error has occurred, errno contains a value that indicates the type of error that has been detected.

See also:

errno, fopen(), fputc(), putc(), puts()

Examples:

#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 );
    }
  }

Classification:

ANSI

Systems:

All (except DOS/PM)