#include <iostream>
using namespace std;
struct student{
char name[10];
int grade;
};
int main() {
struct student s[10];
student s[0].name = "Jack";
cout<<s[0].name;
}
我想创建结构类型数据student
作为一个组合。但是当我这样做的时候,出现了一些错误,我不知道为什么。以下是错误:结构的一些问题
1.error:重新定义's'的不同类型:'student [0]'vs'学生结构[10]”
student s[0].name = "Jack";
^
2.注意:以前的定义是这里
struct student s[10];
^
3.错误:预期 ';'在声明
student s[0].name = "Jack";
^
;
是的,这不编译,缺少';' –
什么错误?这很重要。 – Carcigenicate
严重的说明,请使用'strcpy()'。 –