title: Padding with spaces in char array
body: <p>I am writing a program to write a head for a specific image format. This image format requires 256 characters as its header before any following raw image data. But I have problem padding empty spaces to make the header 256 characters long.</p>
  
  <p>Below is an abstraction of my problem:</p>
  
  <pre><code>char pad[256];
  sprintf( pad, "header info:%s=%f", "scale", 2.3);
  cout&lt;&lt;pad&lt;&lt;"data here"&lt;&lt;endl;
  </code></pre>
  
  <p>The output is:</p>
  
  <pre><code>header info:scale=2.300000data here
  </code></pre>
  
  <p>However, the result I expect is like:</p>
  
  <pre><code>header info:scale=2.300000                            data here
  </code></pre>
  
  <p>where "data here" appears after 256 characters from the beginning of the file.
  How can I change the program to pad empty spaces in the character array?</p>