【发布时间】:2017-10-24 10:46:16
【问题描述】:
#include <stdio.h>
int main () {
struct Record {
int employeeNumber;
char employeeName;
float salary;
int yearsServiced;
} record[5];
struct record[0] = {46723, "Fattah", 4550.00, 8};
printf("TheEmployee number is %d", record[0].employeeNumber);
}
为什么我的程序无法运行?请帮忙。感谢您的提前。
【问题讨论】:
-
struct record[0]声明一个大小为 0 的数组。 -
char employeeName;-->char *employeeName;,struct record[0] = {46723, "Fattah", 4550.00, 8};-->record[0] = (struct Record){46723, "Fattah", 4550.00, 8}; -
我不明白。请进一步解释。为什么需要强制转换(结构记录)?
-
@TeoPeiShen 不要听BLUEPIXY的解法,没错,但在这种状态下会让你迷惑。
-
请查看stackoverflow.com/help/how-to-ask ...您的问题虽然可能会得到解答,但对将来遇到类似问题的任何人都没有帮助,也不会对 StackOverflow 增加任何内容。
标签: c