title: C++ - cout flags work only for first output
body: <p>When i pass some data, output is similiar to <code>xxxxxxxx0x97 0x104 0x111 0x106 0x0</code>
  Why cout formatting is affecting only first output?</p>
  
  <pre><code>void Dumper::hex(const unsigned char * data, size_t len) {
  
          cout &lt;&lt; endl;
  
          ios::fmtflags f(cout.flags());
  
          /*
          cout.fill('0');
          cout.width(2);
          */
  
          cout.fill('x');
          cout.width(10);
  
          for (int i = 0; i &lt; len; i++) {
              cout &lt;&lt; "0x" &lt;&lt; ((long)(data[i]) &amp; 255) &lt;&lt; " ";
          }
  
          cout.flags(f);
          cout &lt;&lt; endl;
  
      }
  </code></pre>