我正在编写一个程序,其中将结构作为参数传递,但出现错误
void main()
{
struct strucintcal
{
char name[20];
int numb;
float amt;
} xyz;
void intcal(struct strucintcal);
printf("\n Enter Customer Name: ");
gets(xyz.name);
printf("\nEnter Customer Nuber: ");
scanf("%d",&xyz.numb);
printf("\nEnter principal aomunt: ");
scanf("%f", &xyz.amt);
intcal(xyz);
getch();
}
链接器错误: undefined symbol _intcal
最佳答案
你需要定义void intcal(struct strucintcal);
:
void intcal(struct strucintcal s)
{
s.field...
}
此外,通常通过指针传递结构更好:
void intcal(struct strucintcal *s)
{
s->field...
}
关于C 传递结构作为参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20274475/