title: Storing char array in a class and then returning it
body: <p>I need to store a char array inside a class and then return it. I have to admit that I'm a bit confused about pointers and have tried everything I can think of but can't get it to work. Here's what I have:</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  class Test {
  public:
      void setName(char *name);
      char getName();
  private:
      char m_name[30];
  };
  
  void Test::setName(char *name) {
      strcpy(m_name, name);
  }
  
  char Test::getName() {
      return *m_name;
  }
  
  void main() {
  
      Test foobar;
      char name[] = "Testing";
      foobar.setName(name);
      cout &lt;&lt; foobar.getName();
  }
  </code></pre>
  
  <p>Of course, I expect setName() to store the string "Testing" inside the class, and getName() should return "Testing". But instead, I get only the first letter T. What am I doing wrong?</p>
  
  <p>I guess I should be using std strings but first I would like to understand why this does not work. As far as I know, this should work with char arrays as well?</p>