title: How to conditionally set a C style string in C++?
body: <p>I am using C++ and do not want to use <code>std::string</code>.  I am trying to set the value of a C style string based on the value of a conditional.  Is this possible?</p>
  
  <p>Here is a minimum working example:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  void print_thing(int a)
  {
      char* message;
  
      switch (a)
      {
      case 1:
          message = "case 1";
          break;
      default:
          message = "case 2";
          break;
      }
  
      std::cout &lt;&lt; message &lt;&lt; std::endl;
  }
  
  int main()
  {
      int a{ 5 };
      print_thing(a);
  }
  </code></pre>
  
  <p>This program is not in error but it seems bad form to set a non <code>const</code> <code>char*</code> to a string literal.  Is there a better way to do this?</p>