例14.10 开辟空间以存放一个结构体变量。
#include <string.h>
struct Student
{char name[10];
int num;
char sex;
};
void main ( )
{
Student *p;
p=new Student;
strcpy(p->name,"Wang Fun" );
p->num=10123;
p->sex=′M′;
delete p;
}
#include <string.h>
struct Student
{char name[10];
int num;
char sex;
};
void main ( )
{
Student *p;
p=new Student;
strcpy(p->name,"Wang Fun" );
p->num=10123;
p->sex=′M′;
delete p;
}