//sprintf和sprintf_s的区别是sprintf_s的第二参数指定缓冲区大小,避免溢出风险。
#include <iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
char str[50]={0};char str2[50]={0};
sprintf(str,"%s","HuaTeng-Ma") ;
cout<<sizeof(str2)<<endl;
sprintf_s(str2,sizeof(str2),"%s","HuaTeng-Ma") ;
cout<<str<<endl;
cout<<str2<<endl;
system("pause");
return 0;
}
//运行效果如下