c语言模拟pcb调度

I_love_program_2011 2011-10-29 12:04:32
这样的错误如何修改
都出现这样的错误:e:\os\funtion.cpp(89) : error C2440: '=' : cannot convert from 'const int' to 'char [50]'
There are no conversions to array types, although there are conversions to references or pointers to arrays.

#define MaxSize 50
typedef char ElemType;
typedef struct lNode /*定义pcd结点类型*/
{
int id; /*进程id*/
ElemType pcb_name[MaxSize]; /*进程名称*/
ElemType status[MaxSize]; /*进程状态*/
struct lNode *next; /*指向同一状态的下一个pcb地址*/
struct lNode *all_q_next;/*指向总链的下一个pcb地址*/
int start_addr;/*程序开始地址*/
}pcb;
.
.
.
.
.
void initialize(pcb *&all_head,pcb *&ready_head,pcb *wait_head)
{
//总链队列头指针
all_head=(pcb *)malloc(sizeof(pcb));
all_head->id=0;
all_head->pcb_name=NULL; //有问题
all_head->status=NULL; //有问题

all_head->start_addr=0;
all_head->next=NULL;
all_head->all_q_next=NULL;
//就绪队列头指针
ready_head=(pcb *)malloc(sizeof(pcb));
ready_head->id=0;
ready_head->pcb_name=NULL; //有问题
ready_head->status=NULL; //有问题
ready_head->start_addr=0;
ready_head->next=NULL;
ready_head->all_q_next=NULL;
//等待队列头指针
wait_head=(pcb *)malloc(sizeof(pcb));
wait_head->id=0;
wait_head->pcb_name=NULL; //有问题
wait_head->status=NULL; //有问题

wait_head->start_addr=0;
wait_head->next=NULL;
wait_head->all_q_next=NULL;
}
...全文
150 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
jiuchang 2011-10-29
  • 打赏
  • 举报
回复
all_head->pcb_name=NULL; //有问题
all_head->status=NULL; //有问题

这两个成员是数组了,不能这样赋值。应该如下:
memset(all_head->pcb_name, 0, sizeof(all_head->pcb_name));

70,020

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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