小编Sar*_*ah 的帖子

如何修复此左值警告?

我的代码是:

void main() {
 person student[10];

 student[0].names[0] = 'C';
 student[0].names[1] = 'a';
 student[0].names[2] = 'm';
 student[0].names[3] = 'i';
 student[0].ages = 16;
 student[0].sex[0] = 'F';
 student[0].sex[1] = 'e';
 student[0].sex[2] = 'm';
 student[0].sex[3] = 'a';
 student[0].sex[4] = 'l';
 student[0].sex[5] = 'e';
 student[0].month = 8;
 student[0].day = 2;
 student[0].year = 1993;
}
Run Code Online (Sandbox Code Playgroud)

所有的"学生"都有下划线说,表达必须是可修改的左值.我怎样才能解决这个问题?

person

typedef struct person 
{ 
char names[20][10]; 
char sex[6][10]; 
int ages[10]; 
int month[10]; 
int day[10]; 
int year[10]; 
} person;
Run Code Online (Sandbox Code Playgroud)

c++ arrays

4
推荐指数
1
解决办法
412
查看次数

标签 统计

arrays ×1

c++ ×1