【发布时间】:2022-01-22 06:48:26
【问题描述】:
struct student {
char name[20];
int age;
float mobile;
char address[20];
};
struct student Amit;
Amit.name[20] = "Sachin"; // I have mentioned the size still warning and unexpected result! why?
输出:
$ gcc try.c try.c:在函数'main'中: try.c:12:17:警告:赋值使指针从没有强制转换的整数 [-Wint-conversion] s1.name[20] = "萨钦"; ^ $ ./a.exe ☺
【问题讨论】:
标签: arrays c struct initialization string-literals