qq_36299965 2016-12-14 12:12 采纳率: 100%
浏览 942
已采纳

c语言,结构体求助,实在找不出原因

#include
struct student
{
int num;
char name[10];
float score[3];
}students[5],*p;
int main()
{
void print(struct student *p);
int I;
for(p=students;p

{
scanf("%d%s",&p->num,p->name);
for(i=0;i scanf("%f",&up->score[i]);
}
print(students);
return 0;
}
void print (struct student *p)
{
int I;
for(;p

{
printf("%d%s",p->num,p->name);
for(i=0;i printf("%f",p->score[i];
}
}
void print(struct student *p)这句一直出现警告。个人感觉没有什么问题。
警告语句:
warning:'struct student' declared inside
parameter list
warning:its scope is only this definition or declaration ,which is probably not what
实在是不懂为什么,求大大解释

  • 写回答

3条回答 默认 最新

  • 小灸舞 2016-12-15 02:35
    关注

    你有好多小错误:
    1.少括号
    2.int i而不是int I
    3.将声明对应的语句放在前部,以保证该声明在使用前已经被找到。
    改成这样:

     #include<stdio.h>
    struct student
    {
        int num;
        char name[10];
        float score[3];
    }students[5], *p;
    void print(struct student *p);
    int main()
    {
        int i;
        for (p = students; p<p + 5; p++)
        {
            scanf("%d%s", &p->num, p->name);
            for (i = 0; i<3; i++)
                scanf("%f", &p->score[i]);
        }
        print(students);
        return 0;
    }
    void print(struct student *p)
    {
        int i;
        for (; p<p + 5; p++)
        {
            printf("%d%s", p->num, p->name);
            for (i = 0; i<3; i++)
                printf("%f", p->score[i]);
        }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘