在C中设置struct属性的默认值

 红殿_真红王道哥哥 发布于 2023-01-15 12:59

我有一个结构(在C语言中)声明如下:

struct readyQueue
{
    int start;
    int total_CPU_burst;
    int CPU_burst;
    int CPU_bursted;
    int IO_burst;
    int CPU;
    struct readyQueue *next;
};
struct readyQueue *readyStart = NULL;
struct readyQueue *readyRear = NULL;

readyStart = mallow(sizeof(struct readyQueue) * 1);
readyRear = mallow(sizeof(struct readyQueue) * 1);

我想设置readyStart-> CPU = -1,readyRead-> CPU = -1,CPUchoose-> CPU = -1默认情况下,这意味着如果我声明新的readyQueue结构,就像那样

struct readyQueue *CPUchoose = NULL;
CPUchoose = mallow(sizeof(struct readyQueue) * 1);

然后CPUchoose-> CPU也= = -1,我试图像这样delare readyQueue

 struct readyQueue
    {
        int start;
        int total_CPU_burst;
        int CPU_burst;
        int CPU_bursted;
        int IO_burst;
        int CPU = -1;
        struct readyQueue *next;
    };

但是,当我构建代码时,它会显示错误,任何人都可以帮助我

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有