[Previous]
[Contents]
[Next]

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 isn't written.

Returns:

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.

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

Safety:
Interrupt handler No
Signal handler No
Thread Yes

See also:

errno, ferror(), fopen(), fputc(), fputchar(), putc(), putchar(), puts()


[Previous]
[Contents]
[Next]