Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
Miscellaneous
C Library
cassert (assert.h)
cctype (ctype.h)
cerrno (errno.h)
cfloat (float.h)
ciso646 (iso646.h)
climits (limits.h)
clocale (locale.h)
cmath (math.h)
csetjmp (setjmp.h)
csignal (signal.h)
cstdarg (stdarg.h)
cstddef (stddef.h)
cstdio (stdio.h)
cstdlib (stdlib.h)
cstring (string.h)
ctime (time.h)
cstdio (stdio.h)
functions:
clearerr
fclose
feof
ferror
fflush
fgetc
fgetpos
fgets
fopen
fprintf
fputc
fputs
fread
freopen
fscanf
fseek
fsetpos
ftell
fwrite
getc
getchar
gets
perror
printf
putc
putchar
puts
remove
rename
rewind
scanf
setbuf
setvbuf
sprintf
sscanf
tmpfile
tmpnam
ungetc
vfprintf
vprintf
vsprintf
macro constants:
EOF
FILENAME_MAX
NULL
TMP_MAX
objects:
stderr
stdin
stdout
types:
FILE
fpos_t
size_t


fputs

function
<cstdio>
int fputs ( const char * str, FILE * stream );

Write string to stream

Writes the 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 final null-character is not copied to the stream.

Parameters

str
An array containing the null-terminated sequence of characters to be written.
stream
Pointer to a FILE object that identifies the stream where the string is to be written.

Return Value

On success, a non-negative value is returned.
On error, the function returns EOF.

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,255,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