Professional Documents
Culture Documents
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define ALLOCATED 1
#define NOTALLOCATED 0
struct file
{
char name[25];
int size;
int allocated;
struct file *next;
};
if(f == NULL)
f= temp;
else
{
temp1=f;
while(temp1->next!=NULL)
temp1=temp1->next;
temp1->next = temp;
}
return f;
}
int main()
{
int bsize,fsize;
char name[25],choice;
struct file *f = NULL;
printf("\n\nEnter memory block size:");
scanf("%d",&bsize);
while(1)
{
printf("\nEnter file name :");
scanf("%s",name);
printf("Enter the size:");
scanf("%d",&fsize);
f = insert(f,name,fsize);
printf("Do you want to continue (Y/N):");
do
{
scanf("%c",&choice); // instead of using this do .. while loop ,fflush(stdin) can be used but
its not ansi standard
}
while(choice == '\n');
if(choice == 'N' || choice == 'n')
break;
}
cma(f,bsize);
return 0;
}
OUTPUT
Memory Blocks
0 |------------------------|
| v1 20 |
20 |------------------------|
| v2 40 |
60 |------------------------|
| v3 30 |
90 |------------------------|
| |-1
99 |------------------------|