{
len = std::strlen(s);
str = new char[len + 1];
std::strcpy(str, s);
num_strings++;
}
提示: 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.
6 个解决方案
#1
class String
{
private:
char *str;
int len;
static int num_strings;
static const int CINLIM = 80;
public:
String(const char *s);
}
{
private:
char *str;
int len;
static int num_strings;
static const int CINLIM = 80;
public:
String(const char *s);
}
#2
strcpy不安全,你可以用strcpy_s代替它
#3
strcpy_s需要三个参数,不支持两个参数。改为strcpy(str,len+1,s)
#4
写错了,应该是改为strcpy_s(str,len+1,s)
#5
use _CRT_SECURE_NO_WARNINGS
#6
#pragma warning(disable:4996)
...
#1
class String
{
private:
char *str;
int len;
static int num_strings;
static const int CINLIM = 80;
public:
String(const char *s);
}
{
private:
char *str;
int len;
static int num_strings;
static const int CINLIM = 80;
public:
String(const char *s);
}
#2
strcpy不安全,你可以用strcpy_s代替它
#3
strcpy_s需要三个参数,不支持两个参数。改为strcpy(str,len+1,s)
#4
写错了,应该是改为strcpy_s(str,len+1,s)
#5
use _CRT_SECURE_NO_WARNINGS
#6
#pragma warning(disable:4996)
...