title: Interaction between setw and double quoted string character
body: <p>I'm trying to make a receipt, andbalways want the  " kg" to be ONE SPACE after the weight, and also "$" just before both 'costperkg' and 'totacost' Initially using setw to format the output, could not get it to work, got it done with ostringstream. I Can anyone explain why does pushing double quote string does not work?</p>
  
  <p>This one does not work :</p>
  
  <pre class="lang-cpp prettyprint-override"><code>int main()
  {
  string item = "A" ;
  double weight = 2.00 ;
  double costperkg = 1.98 ;
  double totalcost = 3.96 ;
  
  cout &lt;&lt; fixed &lt;&lt; showpoint &lt;&lt; setprecision(2);
  
  cout &lt;&lt; setw(14) &lt;&lt; left &lt;&lt; "ITEM" &lt;&lt; setw(16) &lt;&lt; "WEIGHT" &lt;&lt; setw(18) &lt;&lt; "COST/kg" 
  &lt;&lt; setw(14) &lt;&lt; "COST" &lt;&lt; endl ;
  
  cout &lt;&lt; setw(14) &lt;&lt; left &lt;&lt; item &lt;&lt; setw(16) &lt;&lt; weight &lt;&lt; "kg" &lt;&lt; setw(18) &lt;&lt; "$" 
  &lt;&lt; costperkg &lt;&lt; setw(14) &lt;&lt; "$" &lt;&lt; totalcost &lt;&lt; endl &lt;&lt; endl ;
  }
  </code></pre>
  
  <p>This one works:</p>
  
  <pre><code>ostringstream streamweight, streamcostperkg, streamtotalcost;
      streamweight &lt;&lt; fixed &lt;&lt; showpoint &lt;&lt; setprecision(2) &lt;&lt; weight ;
      streamcostperkg &lt;&lt; fixed &lt;&lt; showpoint &lt;&lt; setprecision(2) &lt;&lt; costperkg ;
      streamtotalcost &lt;&lt; fixed &lt;&lt; showpoint &lt;&lt; setprecision(2) &lt;&lt; totalcost ;
  
      string strweight = streamweight.str() + " kg" ; 
      string strcostperkg = "$" + streamcostperkg.str() ;
      string strtotalcost = "$" + streamtotalcost.str() ;
  
  
      cout &lt;&lt; setw(14) &lt;&lt; left &lt;&lt; item &lt;&lt; setw(16) &lt;&lt; strweight &lt;&lt; setw(18) &lt;&lt; strcostperkg 
  &lt;&lt; setw(14) &lt;&lt; strtotalcost &lt;&lt; endl &lt;&lt; endl ;
  </code></pre>
  
  <p>The expected result is :<code>
  ITEM          WEIGHT           COST/kg            COST
  A             2.0 kg           $1.98              $3.96
  </code>
  What I got instead is :
  <code>
  ITEM          WEIGHT          COST/kg           COST
  A             2.00            kg$                 1.98$             3.96
  </code></p>
  
  <p>Why does the setw one not work? and also for those viewing on phone, the first character from first and second life of every word should align on the first letter (A, 2, $, $)</p>