Write string to stdout puts():
Writes the C string pointed by str to stdout and appends a newline character ('\n').
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 stdout.
Using fputs(str,stdout) instead, performs the same operation as puts(str) but without appending the newline character at the end.
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 stdout.
Using fputs(str,stdout) instead, performs the same operation as puts(str) but without appending the newline character at the end.
|
Write string to stream fputs():
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.
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.
/* 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;
}
Return Value
On success, a non-negative value is returned.
On error, the function returns EOF.
No comments:
Post a Comment