问题遇到的现象和发生背景
问题相关代码,请勿粘贴截图
运行结果及报错内容
我的解答思路和尝试过的方法
我想要达到的结果
#include <stdio.h>
#include <stdlib.h>
#define minsize 10
typedef struct free_table{
long address;
long size;
struct free_table *next;
}Node,*NodeList ;
NodeList head;
void createLink()
{
NodeList p;
int n;
head=(NodeList)malloc(sizeof(Node));
p=head;
printf("请输入空闲区域数:");
scanf("%d", &n);
while( n-- ) {
p->next = (NodeList)malloc(sizeof(Node));
p = p->next;
scanf("%d", &p->address);
scanf("%d", &p->size);
}
p->next = NULL;
}
void Best_allocate(int request)
{
}
void Link_printf()
{
NodeList temp1;
temp1=head->next;
printf("分配后的空闲表如下:\n" );
while(temp1){
printf("空闲起始地址为:%d;长度为:%d\n",temp1->address,temp1->size );
temp1=temp1->next ;
}
}
main()
{
int a,request;
createLink();
printf("请输入作业申请长度:");
scanf("%d",&request);
Best_allocate(request);
Link_printf();
}