title: C++ : Why I can't print a const char* with sprintf?
body: <p>What am I missing here ? It's driving me nuts !</p>
  
  <p>I have a function that returns a <strong>const char*</strong></p>
  
  <pre><code>const char* Notation() const
  {
      char s[10];
      int x=5;
      sprintf(s, "%d", x);
      return s;
  }
  </code></pre>
  
  <p>Now in another part of the code I am doing this :</p>
  
  <pre><code>.....
  .....
  char str[50];       
  sprintf(str, "%s", Notation());
  .....
  .....
  </code></pre>
  
  <p>but <strong>str</strong> remains unchanged.</p>
  
  <p>If instead I do this :</p>
  
  <pre><code>.....
  .....
  char str[50];
  str[0]=0;
  strcat(str, Notation());
  .....
  .....
  </code></pre>
  
  <p><strong>str</strong> is correctly set. </p>
  
  <p>I am wondering why <strong>sprintf</strong> doesn't work as expected...</p>