c语言的问题找错
来源:百度知道 编辑:UC知道 时间:2024/05/22 15:33:47
#include <stdio.h>
void main()
{
int i;
struct student
{
int number;
char name[20];
char address[40];
};
struct student student1[2];
for(i=0;i<2;i++)
{
char c;
puts("please input number,name and address:");
scanf("%d",student1[i].number);
c=getchar();
gets(student1[i].address);
gets(student1[i].name);
}
for(i=0;i<2;i++)
printf("%d %s %s",student1[i].number,student1[i].name,student1[i].address);
}
void main()
{
int i;
struct student
{
int number;
char name[20];
char address[40];
};
struct student student1[2];
for(i=0;i<2;i++)
{
char c;
puts("please input number,name and address:");
scanf("%d",student1[i].number);
c=getchar();
gets(student1[i].address);
gets(student1[i].name);
}
for(i=0;i<2;i++)
printf("%d %s %s",student1[i].number,student1[i].name,student1[i].address);
}
scanf("%d",&student1[i].number);
scanf用的是地址。
另外,你程序中的输入和输出的顺序是不一样的。
一楼的同志:c用来打酱油会漏光的,还是用u、v、G、w、x、y来打酱油吧!
你没事吧,这没有错误啊!
如有你列出/*****found*******/看下
scanf("%d",student1[i].number);改成scanf("%d",&student1[i].number);
puts("please input number,address and name :");
scanf("%d",&student1[i].number);
scanf("%d",&student1[i].number);
应该是:scanf("%d",student1[i].number);改成scanf("%d",&student1[i].number);