You were redirected to cplusplus.com/fputs || See search results for: "fputs"
function
<cstdio>

fputs

int fputs ( const char * str, FILE * stream );
Write string to stream
Writes the C string pointed by str to the stream.

The function begins copying from the address specified (str) until it reaches the terminating null character ('\0'). This terminating null-character is not copied to the stream.

Notice that fputs not only differs from puts in that the destination stream can be specified, but also fputs does not write additional characters, while puts appends a newline character at the end automatically.

Parameters

str
C string with the content to be written to stream.
stream
Pointer to a FILE object that identifies an output stream.

Return Value

On success, a non-negative value is returned.
On error, the function returns EOF and sets the error indicator (ferror).

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/* fputs example */
#include <stdio.h>

int main ()
{
   FILE * pFile;
   char sentence [256];

   printf ("Enter sentence to append: ");
   fgets (sentence,256,stdin);
   pFile = fopen ("mylog.txt","a");
   fputs (sentence,pFile);
   fclose (pFile);
   return 0;
}


This program allows to append a line to a file called mylog.txt each time it is run.

See also