#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 的数组。您打算初始化数组的第一个元素,但混淆了声明和索引:
struct Record myRecord[1] = {46723, "Fattah", 4550.00, 8};
这声明了一个大小为 1 的数组,并使用给定值初始化第一个元素。
关于C语言编程结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46908478/