• // crt_fputs.c // This program uses fputs to write // a single line to the stdout stream. #
  • printf ("Enter sentence to append: "); fgets (sentence,256,stdin); pFile = fopen ("mylog.txt","a"); fputs (sentence,pFile); fclose (pFile); return 0
  • fputs. (php 4, php 5, php 7, php 8). fputs — Alias of fwrite().
  • The fputs() and fgets() in C programming are used to write and read strings from streams.
  • Writes every character from the null-terminated string str to the output stream stream, as if by repeatedly executing std::fputc. The terminating null character from str is not written.
  • The fputs() function writes the character string pointed to by buf to the output stream designated by fp.
  • The functions fputs() and puts() may also fail and set errno for any of.
  • In line 16 and 17, two printf() statements string "Testing fputs() function: \n\n" and "To stop reading press Ctrl+Z in windows and Ctrl+D in Linux : \n\n" to the console.
  • By following the steps outlined in this guide, you can easily use the fputs() function in your PHP projects to write data to files.
  • int fputs( const char * string, FILE * filestream )