bubbleTg 2016-12-14 01:02 采纳率: 75%
浏览 2120
已采纳

assignment from incompatible pointer type

请问大神这个怎么解决??谢谢了
代码如下:

#include<stdio.h>
#include<stdlib.h>
struct student {    //xtudent 学籍;
    int c;          //长
    int k;          //宽
    int g;          //高
    char name[9];   //姓名
    struct stdent *next;
};
typedef struct student student;
int main()
{
    int n;
    while (scanf("%d", &n))
    {
        if (n != -1) {
            int j;
            student *p_head, *p_rail, *p_st;
            p_head = (student *)malloc(sizeof(student));
            p_rail = p_head;
            int lfn[9];                 //储存体积
            char *lfnch[10];            //用于储存要找的名字
            for (j = 0; j < n; j++)
            {
                p_st = (student *)malloc(sizeof(student));
                scanf("%d %d %d %s", &(p_st->c), &(p_st->k), &(p_st->g), p_st->name);
                p_rail->next = p_st;
                p_rail = p_st;
                lfn[j] = (p_st->c)*(p_st->k)*(p_st->g); //把体积储存在数组中;
                lfnch[j] = (p_st->name);    //分别把名字储存在数组中;
            }
            int min = lfn[0], max = lfn[0],pos1,pos2;
            for (j = 1; j < n; j++)             //找到体积最大最小并标记下标;
            {
                if (min > lfn[j])
                {
                    min = lfn[j];
                    pos1 = j;
                }
                else pos1 = 0;
                if (max < lfn[j])
                {
                    max = lfn[j];
                    pos2 = j;
                }

            }
            printf("%s took clay from %s\n", lfnch[pos2], lfnch[pos1]);
            min = 0, max = 0;
        }
        else
            break;

    }
    return 0;
}


图片说明

  • 写回答

1条回答 默认 最新

  • 飘飘白云 博客专家认证 2016-12-14 01:07
    关注

    笔误:

    struct student { //xtudent 学籍;
    int c; //长
    int k; //宽
    int g; //高
    char name[9]; //姓名
    struct student *next;
    };

    仔细看粗体部分。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 高价求中通快递查询接口
  • ¥15 解决一个加好友限制问题 或者有好的方案
  • ¥15 关于#java#的问题,请各位专家解答!
  • ¥15 急matlab编程仿真二阶震荡系统
  • ¥20 TEC-9的数据通路实验
  • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
  • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?