title: C++: Format not a string literal and no format arguments
body: <p>I've been trying to print a string literal but seems like I'm doing it wrong, since I'm getting a warning on compilation. It's probably due to wrong formatting or my misunderstanding of <code>c_str()</code> function, which I assume should return a <code>string</code>.</p>
  
  <pre><code>parser.y: In function ‘void setVal(int)’:
  parser.y:617:41: warning: format not a string literal and no format arguments [-Wformat-security]
  </code></pre>
  
  <p>Line 617:</p>
  
  <pre><code>sprintf(temp, constStack.top().c_str());
  </code></pre>
  
  <p>Having those declarations</p>
  
  <pre><code>#include &lt;stack&gt;
  const int LENGTH = 15;
  char *temp = new char[LENGTH];
  stack&lt;string&gt; constStack;
  </code></pre>
  
  <p>How can I provide a proper formating to string?</p>