一个关于strcpy_s的问题
#include<cstring>#include<iostream>
using namespace std;
class score
{int no;
char name[8];
int math;
int phi;
int data;
int ave;
public:
void write(int a,int b,int c,int d,char*p)
{no=a;math=b;phi=c;data=d;strcpy_s(name,p);name[sizeof(name)-1]='\0';}
void average()
{ave=(math+phi+data)/3;}
void display(score m)
{cout<<"学号"<<m.no<<"姓名"<<name<<"数学"<<m.math<<"物理"<<m.phi<<"数据结构"<<m.data<<"平均分"<<m.ave<<endl;}
};
int main()
{score s[3];
s[1].write(1001,80,70,60,"zhou");
s[1].average;
s[2].write(1002,90,80,85,"chen");
s[2].average;
s[3].write(1003,70,75,89,"wang");
s[3].average;
s[1].display(s[1]);
s[2].display(s[2]);
s[3].display(s[3]);
}
下面是报错信息:
E:\C程序\类和对象\2.cpp(13) : error C2065: 'strcpy_s' : undeclared identifier
E:\C程序\类和对象\2.cpp(22) : warning C4551: function call missing argument list
E:\C程序\类和对象\2.cpp(24) : warning C4551: function call missing argument list
E:\C程序\类和对象\2.cpp(26) : warning C4551: function call missing argument list
E:\C程序\类和对象\2.cpp(30) : warning C4508: 'main' : function should return a value; 'void' return type assumed
Error executing cl.exe.
2.obj - 1 error(s), 4 warning(s)
为什么头文件加了cstring,strcpy还没法用?warning C5551:---啥意思?我用的c++6.0