谁能帮我看下这程序出什么问题了,先谢谢了!
#include "stdafx.h"
#include <iostream>
#include <conio.h>
#include <iomanip>
#include <cerrno>
using std::cin;
using std::cout;
using std::endl;
using std::setw;
int _tmain(int argc, _TCHAR* argv[])
{
const int MAX = 50;
char Str1[MAX];
char Str2[MAX];
char* instead[MAX];
cout << "请输入目标字符串:";
cin.getline( Str1,MAX,'\n');
cout << "请输入源字符串:";
cin.getline( Str2,MAX,'\n');
int count = 0;
while( Str2 != 0 )
{
count ++;
instead[count] = &Str2[count];
}
errno_t error = strcat_s(Str1,MAX,*instead);
if( error == 0 )
{
cout << "恭喜,字符串拼接成功!"
<< endl
<< "拼接结果:" << strcat(Str1,*instead);
}
else
if( error == EINVAL )
cout << "字符串拼接失败,原因是目标或源为NULL";
else
if( error == ERANGE)
cout << "字符串拼接失败,原因是目标长度太短";
cout << endl
<< "Press any key . . .";
_getch();
return 0;
}