title: How can I initialize char arrays in a constructor?
body: <p>I'm having trouble declaring and initializing a char array.  It always displays random characters.  I created a smaller bit of code to show what I'm trying in my larger program:</p>
  
  <pre><code>class test
  {
      private:
          char name[40];
          int x;
      public:
          test();
          void display()
          {
              std::cout&lt;&lt;name&lt;&lt;std::endl;
              std::cin&gt;&gt;x;
          }
  };
  test::test()
  {
      char name [] = "Standard";
  }
  
  int main()
  {   test *test1 = new test;
      test1-&gt;display();
  }
  </code></pre>
  
  <p>And sorry if my formatting is bad, I can barely figure out this website let alone how to fix my code :(</p>