函数这样怎么不行

来源:百度知道 编辑:UC知道 时间:2024/05/10 05:30:52
#include<stdio.h>
#include<conio.h>
void input(struct sell_record a[50],int count)
{
char c;
while(c=='N' || c=='n')
{
printf("请输入姓名");
scanf("%s",&a[count].name);
printf("请输入金额");
scanf("%f",&a[count].income);
}
}
struct sell_record
{
char name[20];
float income;
};
void main()
{
int count=0;
struct sell_record sells[50];
input(sells,count);
}
为什么我的函数里面的scanf("%s",&a[count].name);
scanf("%f",&a[count].income);
老师报错啊=.=那为高手告诉我下XX

你这是C还是C++?

a[count].income 这样使用指针 是C里是错误的

a[count]->income 这样

结构体的定义 应在最前面

struct sell_record sells[50];
这句是什么东西?
你好好看看书再写吧

scanf("%s",&a[count].name);
char name[20];
你定义的是数组啊
能怎么输入吗

name是数组.name代表数组首地址
scanf("%s",&a[count].name); 这个就不要再取址了
scanf("%s",a[count].name);

VC里除了结构体顺序报错外一切正常.不要再TC了哈哈.