2.1.9.10 fputs


Description

This function copies string to the output stream at the current position.

Syntax

int fputs( const char * str, FILE * stream )

Parameters

str
Output string
stream
Pointer to FILE

Return

Returns a nonnegative value if it is successful. On an error, fputs returns EOF.

Examples

EX1

//The following example use fputs to write a single line to the file fputs.out

void test_fputs()
{
	  FILE *stream;
	  
	  // Open for write
	  stream = fopen( "fputs.out", "w+" );
	  if( stream == NULL )
	      printf( "The file 'data' was not opened\n" );
	  else
	  {
	      fputs( "Hello world from fputs.\n", stream );
	      // Close stream 
	      fclose( stream );
	  }
}

Remark

See Also

fgets

Header to Include

origin.h

Reference