谁知道 strncpy 这个函数是做什么用的?他的语法格式是什么?
#include<iostream>
#include<string.h>
using namespace std;
class student
{
public:
student(char * pname)
{
cout<<"constructing student"<<pname<<endl;
strncpy(name,pname,sizeof(name));
name[sizeof(name)-1]='\0';
}
~student()
{
cout<<"destructing"<<name<<endl;
}
protected:
char name[20];
};
void main()
{
student ss("jenny");
}
没写错 不是 STRCPY!!!