title: fputs vs. fprintf and double
body: <p>I need to put out a double value into an file.
  So for all my other string i have to put out i use fputs because i think and timed it that fputs is faster then fprintf.</p>
  
  <p>But if i want to put out the double value i can't do this with fputs so i tried fprintf. This is very slow. I need more time if i replace the fprintf and puts there an fputs("TEST",file);</p>
  
  <p>How can i put out the double as fast as the string. Need i to convert it first to string?</p>
  
  <p>I found some conversion. But if i use them i am as slow as if i use the fprintf.</p>
  
  <p>So how can i put out the double to a file so fast as if i put out a string to the file?</p>
  
  <pre><code>  fputs("TEST",fileout); //FAST
    fprintf(fileout, "%f",p); //SLOW
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>Times with fprintf double:</p>
  
  <pre><code>END.PROCESSING.DATA: 2013-04-26 08:10:33.000
  END.CALC.IN.FILE: 2013-04-26 08:11:13.000
  </code></pre>
  
  <p>Times with fputs strings:</p>
  
  <pre><code>END.PROCESSING.DATA: 2013-04-26 08:14:10.000
  END.CALC.IN.FILE: 2013-04-26 08:14:37.000
  </code></pre>
  
  <p>The code for that times:</p>
  
  <pre><code>now = time (0);
  strftime (buff, 100, "%Y-%m-%d %H:%M:%S.000", localtime (&amp;now));
  printf ("END.PROCESSING.DATA: %s\n", buff);
  
  //output file
  FILE *fileout;
  fileout = fopen("out.txt","w");
  double p;
  for(i=0; i&lt;17000;i++){
    for(j=0; j&lt;i;j++){
      for(z=0;z&lt;400;z++){
        //DO SOME WORK
      }
      p = 1.0;
      fputs(allsubsts[i],fileout);
      fputs(";",fileout);
      fputs(allsubsts[j],fileout);
      fputs(";",fileout);
      //fprintf(fileout, "%.21g", p);
      fputs("TEST",fileout);
      fputs(";\n",fileout);
    }
  }
  fclose(fileout);
  
  now = time(0);
  strftime(buff,100,"%Y-%m-%d %H:%M:%S.000", localtime(&amp;now));
  printf("END.CALC.IN.FILE: %s\n",buff);
  </code></pre>
  
  <p>Changes between the time are only the change that i put the double instead the TEST string in the file.</p>