title: C++ Weird characters printed to the screen
body: <p>Thank you sp2danny for the answer!</p>
  
  <p>HEADER FILE:</p>
  
  <pre><code>#ifndef EMPLOYEERECORD_H
  #define EMPLOYEERECORD_H
  
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  using namespace std;
  
  class EmployeeRecord
  {
      char m_sLastName[31];  // employee last name
      char m_sFirstName[31]; // employee first name
  
      EmployeeRecord();     // default constructor
      EmployeeRecord(int ID, char *fName, char *lName, int dept, double sal);
  };
  
  #endif
  </code></pre>
  
  <p>SOURCE FILE:</p>
  
  <pre><code>#include "EmployeeRecord.h"
  
  //constructor 1 (default)
  EmployeeRecord::EmployeeRecord()
  {
      m_iEmployeeID = 0;
      m_sLastName == "";
      m_sFirstName == "";
      m_iDeptID = 0;
      m_dSalary = 0.0;
  }
  
  // this constructor shall set the member variables to the values passed into the function
  EmployeeRecord::EmployeeRecord(int ID, char *fName, char *lName, int dept, double sal)
  {
      unsigned int i = 0;
      m_iEmployeeID = ID;
      for (i = 0; i &lt; 31; i++)
      {
          m_sFirstName[i] = *(fName + i);
          m_sLastName[i] = *(lName + i);
      }
      m_iDeptID = dept;
      m_dSalary = sal;
  }
  
  // destructor - cleans up and deallocates any memory that pointers within this class may have referenced to
  EmployeeRecord::~EmployeeRecord(){};
  
  
  // this function shall print to the screen all data found in the employee's record
  void EmployeeRecord::printRecord()
  {
      cout &lt;&lt; "Employee ID:     " &lt;&lt; m_iEmployeeID &lt;&lt; endl;
      cout &lt;&lt; "First Name:      " &lt;&lt; m_sFirstName &lt;&lt; endl;
      cout &lt;&lt; "Last Name:       " &lt;&lt; m_sLastName &lt;&lt; endl;
      cout &lt;&lt; "Department ID:   " &lt;&lt; m_iDeptID &lt;&lt; endl;
      cout &lt;&lt; "Salary:        $ " &lt;&lt; m_dSalary &lt;&lt; endl;
  }
  </code></pre>
  
  <p>HOW I CALL IT:</p>
  
  <pre><code>/*******************************************************************
  *   main function for project Prog1
  *******************************************************************/
  
  #include &lt;stdio.h&gt;
  #include &lt;time.h&gt;
  #include &lt;cstdlib&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;windows.h&gt;
  
  #include &lt;string&gt;
  #include &lt;iostream&gt;
  using namespace std;
  
  #include "EmployeeRecord.h"
  
  int main(void)
  {
  
      int answer, employee_id, dept_id;
      unsigned int i;
      char  firstname[31], lastname[31];
      double *salary, _salary;
  
      salary = &amp;_salary;
  
  
      EmployeeRecord Employee1 = EmployeeRecord();
      firstname[0] = 'J';
      firstname[1] = 'h';
      firstname[2] = 'o';
      firstname[3] = 'n';
      firstname[4] = 'n';
      firstname[5] = 'y';
      lastname[0] = 'D';
      lastname[1] = 'o';
      lastname[2] = 'e';
      lastname[3] = 'b';
      lastname[4] = 'e';
      lastname[5] = 'r';
      EmployeeRecord Employee2 = EmployeeRecord(0, firstname, lastname, 0, 0.0);
      Employee2.printRecord();
      system("pause");
  </code></pre>
  
  <p>So say I have set m_sFirstName equal to "Johnny" and m_sLastName equal to "Doeber" where m_sFirstName[0] = 'J', m_sLastName = 'D', etc...
  Everytime the printRecord function is called, I get this result:</p>
  
  <pre><code>Fist Name: Johnny########################### (2 more spaces than were allocated)
  Last Name: Doeber#########################Johnny###########################
  </code></pre>
  
  <p>where # is the null character (looks very weird in the real program)</p>
  
  <p>So not only is the m_sFirstName not printing the first 3 characters to the screen correctly, but the whole messed up version of m_sFirstName is being added to the end of the m_sLastName character array...</p>
  
  <p>How in the world have I done this to myself?</p>