title: Fast C++ String Output
body: <p>I have a program that outputs the data from an FPGA. Since the data changes EXTREMELY fast, I'm trying to increase the speed of the program. Right now I am printing data like this</p>
  
  <pre><code>for (int i = 0; i &lt; 100; i++) {
      printf("data: %d\n",getData(i));
  }
  </code></pre>
  
  <p>I found that using one printf greatly increases speed</p>
  
  <pre><code>printf("data: %d \n data: %d \n data: %d \n",getData(1),getData(2),getData(3));
  </code></pre>
  
  <p>However, as you can see, its very messy and I can't use a for loop. I tried concatenating the strings first using <code>sprintf</code> and then printing everything out at once, but it's just as slow as the first method. Any suggestions?</p>
  
  <p>Edit: 
  I'm already printing to a file first, because I realized the console scrolling would be an issue. But its still too slow. I'm debugging a memory controller for an external FPGA, so the closer to the real speed the better.</p>