Printing strange result
<p>Why is the call to c2.view() printing out both the ID and name for the customer ID?</p>

<p>I have stared at this for a while and couldn't find a cause.  I have either missed something really obvious or I don't understand how cstrings work :)</p>

<p>Customer.h</p>

<pre><code>#ifndef CUSTOMER_H
#define CUSTOMER_H
 class Customer
 {
 private:
     char accountID[6];
     char name[30];
 public:
     Customer();
     Customer(char[], char[]);
     void view();
     Customer operator=(const Customer&amp;);

 };
#endif
</code></pre>

<p>Customer.cpp</p>

<pre><code>#include &lt;string&gt;
#include &lt;iostream&gt;
#include "Customer.h"
using namespace std;



Customer::Customer()
{
    strcpy(accountID, "");
    strcpy(name, "");
}

Customer::Customer(char acc[], char n[])
{
    strcpy(accountID, acc);
    strcpy(name, n);
}

void Customer::view()
{
    cout &lt;&lt; "Customer name: " &lt;&lt; name &lt;&lt; endl;
    cout &lt;&lt; "Customer ID: " &lt;&lt; accountID &lt;&lt;endl;
}

Customer Customer::operator=(const Customer&amp; right)
{
    strcpy(accountID, right.accountID);
    strcpy(name,  right.name);
    return* this;
}
</code></pre>

<p>Driver.cpp</p>

<pre><code>#include &lt;iostream&gt;
#include "Customer.h"
using namespace std;

int main()
{
    char id[] = "123456";
    char n[] = "Bob";
    Customer c1;
    Customer c2(id, n);
    c1.view();
    c2.view();
    system("pause");
    return 0;
}
</code></pre>

<p>Output:</p>

<pre><code>Customer name:
Customer ID:
Customer name: Bob
Customer ID: 123456Bob
Press any key to continue . . .
</code></pre>
