70,037
社区成员
发帖
与我相关
我的任务
分享
#include "stdafx.h"
#include <iostream>
#include <assert.h>
using namespace std;
#include <iostream>
using namespace std;
struct Student
{
int age;
struct Name //此处LZ定义了一个结构体,名字叫做Name,这是一个结构体,不是一个变量,所以必须重新定义变量
{
char firstName[30];
char secondName[30];
};
};
void main()
{
struct Student stu;
char *p="ok";
strcpy(stu.Name.firstName,p); //同上,stu.Name.firstName中的Name为类型,不是变量,因此不是stu的成员,不能使用"."操作符
}
struct Student
{
int age;
struct Name
{
char firstName[30];
char secondName[30];
}name;
};
void main()
{
struct Student stu;
char *p="ok";
strcpy(stu.name.firstName,p);
}
struct Student
{
int age;
struct Name
{
char firstName[30];
char secondName[30];
}name; //
};
void main()
{
struct Student stu;
char *p="ok";
strcpy(stu.name.firstName,p); //
}
struct Student
{
int age;
struct Name
{
char firstName[30];
char secondName[30];
}name; //注意了
};