下列程序:
#include <iostream>
#include <string>
#include <cstring>
int main()
{
using namespace std;
char charr1[20];
char charr2[20] = "jaguar";
string str1;
string str2 = "panther";
str1 = str2;
strcpy(charr1, charr2);
str1 += " paste";
strcat(charr1, " juice");
int len1 = str1.size();
int len2 = strlen(charr1);
cout << "The string " << str1 << " contains "
<< len1 << " characters.\n";
cout << "The string " << str2 << " contains "
<< len2 << " characters.\n";
cin.get();
return 0;
}
生成的时候总是会出现这错误:
1>f:\c++学习中心\源文件\书中例子\4.复杂结构\9.string类型3\9.string类型3\源.cpp(12): error C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\windows kits\10\include\10.0.10240.0\ucrt\string.h(119): note: 参见“strcpy”的声明
1>f:\c++学习中心\源文件\书中例子\4.复杂结构\9.string类型3\9.string类型3\源.cpp(15): error C4996: 'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\windows kits\10\include\10.0.10240.0\ucrt\string.h(90): note: 参见“strcat”的声明
怎么弄都解决不了,求解答
#include <iostream>
#include <string>
#include <cstring>
int main()
{
using namespace std;
char charr1[20];
char charr2[20] = "jaguar";
string str1;
string str2 = "panther";
str1 = str2;
strcpy(charr1, charr2);
str1 += " paste";
strcat(charr1, " juice");
int len1 = str1.size();
int len2 = strlen(charr1);
cout << "The string " << str1 << " contains "
<< len1 << " characters.\n";
cout << "The string " << str2 << " contains "
<< len2 << " characters.\n";
cin.get();
return 0;
}
生成的时候总是会出现这错误:
1>f:\c++学习中心\源文件\书中例子\4.复杂结构\9.string类型3\9.string类型3\源.cpp(12): error C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\windows kits\10\include\10.0.10240.0\ucrt\string.h(119): note: 参见“strcpy”的声明
1>f:\c++学习中心\源文件\书中例子\4.复杂结构\9.string类型3\9.string类型3\源.cpp(15): error C4996: 'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\windows kits\10\include\10.0.10240.0\ucrt\string.h(90): note: 参见“strcat”的声明
怎么弄都解决不了,求解答