title: Having issues with initializing character array
body: <p>Ok, this is for homework about hashtables, but this is the simple stuff I thought I was able to do from earlier classes, and I'm tearing my hair out. The professor is not being responsive enough, so I thought I'd try here.</p>
  
  <p>We have a hashtable of stock objects.The stock objects are created like so:</p>
  
  <p><code>stock("IBM", "International Business Machines", 2573, date(date::MAY, 23, 1967))
  </code></p>
  
  <p>my constructor looks like:</p>
  
  <pre><code>stock::stock(char const * const symbol, char const * const name, int sharePrice, date priceDate): m_symbol(NULL), m_name(NULL), sharePrice(sharePrice), dateOfPrice(priceDate)
  {    
  setSymbol(symbol);
  setName(name);
  }
  </code></pre>
  
  <p>and setSymbol looks like this: (setName is indentical):</p>
  
  <pre><code>void stock::setSymbol(const char* symbol)  
  {  
  if (m_symbol)  
      delete [] m_symbol;  
  m_symbol = new char[strlen(symbol)+1];  
  strcpy(m_symbol,symbol);  
  }  
  </code></pre>
  
  <p>and it refuses to allocate on the line</p>
  
  <p><code>m_symbol = new char[strlen(symbol)+1];</code></p>
  
  <p>with a std::bad_alloc. name and symbol are declared</p>
  
  <pre><code>char * m_name;  
  char * m_symbol;
  </code></pre>
  
  <p>It's definitely strlen() that is going astray. And it doesn't seem to happen every time. </p>
  
  <pre><code>cout &lt;&lt; symbol &lt;&lt; strlen(symbol); 
  </code></pre>
  
  <p>returns IBM correctly, then crashes</p>