求解,为什么会出现“段错误吐核”

hcx306593120 2014-11-05 05:11:48

1 #include<stdio.h>
2 #define size 6
3 struct code
4 { int nu[size];
5 char str[size];
6 int price[size];
7 int store[size];
8 }goods;//结构体
9
10 int select (int a)
11 { int i;
12 for (i = 0;i <= (size -1);i++)
13 { if(a == goods.nu[i])
14 { printf("number is %d\n",goods.nu[i]);
15 printf("name is %d\n",goods.str[i]);
16 printf("price is %d\n",goods.price[i]);
17 printf("store is %d\n",goods.store[i]);
18 }
19 }
20 }
21
22 int main()//下面可正常运行,到上面出现的段错误
23 { int a,i;
24 printf("input the number of goods\n");
25 for(i=0;i<=size -1;i++)
26 { scanf("%d",&goods.nu[i]);
27 }
28 printf("input the name of goods\n");
29 for(i=0;i<=size -1;i++)
30 { scanf("%s",&goods.str[i]);
31 }
32 printf("input the price of goods\n");
33 for(i=0;i<=size -1;i++)
34 { scanf("%d",&goods.price[i]);
35 }
36 printf("input the store of goods\n");
37 for(i=0;i<=size -1;i++)
38 { scanf("%d",&goods.store[i]);
39 }
40
41 printf("input the number of selected goods\n" );
42 scanf("%d",a);
43 select(a);
44 }
...全文
938 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
hcx306593120 2014-11-06
  • 打赏
  • 举报
回复
新人还不是很会用,话说这个问题能给解释一下吗
LinuxCard 2014-11-05
  • 打赏
  • 举报
回复
这年头,问问题都这么不专业了?

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧