//把字符串复制给另一个字符串,没想到是这样的结果。
//代码出错在字符串cha比ch1大,
//但为什么输出的结果这么怪呢?
#include "stdafx.h"
#include
#include
int main(int argc, char *argv[])
{
using namespace std;
char cha[]="abcde";
char ch1[]="123";//这句如改成 char ch1[]="12"; 或许还能理解 ,但为什么?
cout<<"cha---"<<cha<<endl;
cout<<"ch1---"<<ch1<<endl;
cout<<"-----strcpy(ch1,cha);-----"<<endl;
strcpy(ch1,cha);
cout<<"cha---"<<cha<<endl;
cout<<"ch1---"<<ch1<<endl;
cin.get();
cin.get();
return 0;
}