#include "stdafx.h"
#include "iostream"
using namespace std;
#include "string.h"
class employee{
public:
employee()
{
char name[10]="张三";
char street[10]="博爱";
char city[10]="焦作";
char province[10]="河南";
char post[10]="454450";
//int a=(int)name.size();
//int b=(int)street.size();
//int c=(int)city.size();
//int d=(int)province.size();
//int e=(int)post.size();
//cout<<name<<" "<<street<<" "<<city<<" "<<province<<" "<<post;
}
void changename(char * pname){
strcpy(name,pname);
name[sizeof(name)-1]='\0';
}
void display(){
cout<< name<<" "<< street<<" "<< city<<" "<< province<<" "<< post;
}
protected:
char name[10];
char street[10];
char city[10];
char province[10];
char post[10];
//int a,b,c,d,e;
};
void main()
{ employee sa;
sa.changename("李四");
sa.display();
cin.get();
cin.get();
}
为什么只显示“李四”,后边是乱码(一串“烫”字),请高手给予回答,Thank you!