当我尝试编译此代码时,出现错误:转换为请求的非标量类型。此错误涉及以下行:
func( record);
我可以知道我的代码有什么问题吗?
#include <stdio.h>
#include <string.h>
struct student
{
int id;
char name[30];
float percentage;
};
void func(struct student record);
int main()
{
struct student record[2];
func( record);
return 0;
}
void func(struct student record[]) {
int i;
record[0].id=1;
strcpy(record[0].name, "lembu");
record[0].percentage = 86.5;
record[1].id=2;
strcpy(record[1].name, "ikan");
record[1].percentage = 90.5;
record[2].id=3;
strcpy(record[2].name, "durian");
record[2].percentage = 81.5;
for(i=0; i<3; i++)
{
printf(" Records of STUDENT : %d \n", i+1);
printf(" Id is: %d \n", record[i].id);
printf(" Name is: %s \n", record[i].name);
printf(" Percentage is: %f\n\n",record[i].percentage);
}
}