User Tools

Site Tools


c:stdio.h:fputs

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

c:stdio.h:fputs [2013/01/07 21:39]
158.181.88.241
c:stdio.h:fputs [2013/01/22 22:02] (current)
Line 1: Line 1:
 +{{keywords>wiki library source code example reference}}
 +====== fputs ======
 +
 +<code c>
 +    int fputs(const char *str, FILE *stream); 
 +</code>
 +
 +Writes str, to (output) stream stream. Returns non-negative on success or EOF on error.
 +
 +===== C Sourcecode Example =====
 +<code c>
 +/* 
 + * fputs example code
 + * http://code-reference.com/c/stdio.h/fputs 
 + */
 +
 +
 +#include <stdio.h> /* including standard library */
 +//#include <windows.h> /* uncomment this for Windows */
 +
 +int main( void )
 +{     
 +  FILE *stream;
 +  
 +  if((stream=fopen("test.txt","w"))==NULL) {
 +    printf("Cannot open file for writing.\n");
 +    return 1;
 +  }
 +
 +  fputs("Test 1234", stream);
 +  fclose(stream);
 +
 +  return 0;
 +}
 +</code>
 +
 +==== fputs output example ====
 +    output: ./fputs
 +
 +content of test.txt
 +<code c>
 +Test 1234
 +</code>    
  
advertising

Impressum Datenschutz