fputs
int fputs (const char * string , FILE * stream); | stdio.h |
cplusplus.com |
Write string to a stream.
Writes string to the current position of the given
stream.
The function begins copying from the address specified
(string) until it reaches a null character ('\0') that
ends the string. The final null-character is not copied to the stream.
Parameters.
Return Value.
On success, a non-negative value is returned.
On error the function returns EOF.
Example.
/* personal diary */
#include <stdio.h>
main ()
{
FILE * pFile;
char sentence [256];
printf ("Enter sentence to append: ");
fgets (sentence,255,stdin);
pFile = fopen ("diary.txt","at");
fputs (sentence,pFile);
fclose (pFile);
return 0;
}
This program allows to append a line to a file
called diary.txt each time you run it.
See also.
fgets,
gets,
puts,
fprintf,
fscanf