0% found this document useful (0 votes)
0 views

OS_Lab-9

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

OS_Lab-9

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Operating Systems Laboratory (BCS303)

9. Develop a C program to simulate the Linked file allocation strategies


#include<stdio.h>
struct file
{
char fname[10];
int start,size,block[10];
}f[10];
int main()
{
int i,j,n;
printf("Enter no. of files:");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("Enter file name:");
scanf("%s",&f[i].fname);
printf("Enter starting block:");
scanf("%d",&f[i].start);
f[i].block[0]=f[i].start;
printf("Enter no.of blocks:");
scanf("%d",&f[i].size);
printf("Enter block numbers:");
for(j=1;j<=f[i].size;j++)
{
scanf("%d",&f[i].block[j]);
}
}
printf("File\tstart\tsize\tblock\n");
for(i=0;i<n;i++)
{
printf("%s\t%d\t%d\t",f[i].fname,f[i].start,f[i].size);
for(j=1;j<=f[i].size-1;j++)
printf("%d--->",f[i].block[j]);
printf("%d",f[i].block[j]);

Department of Artificial Intelligence & Machine Learning, BIT Page 1


Operating Systems Laboratory (BCS303)

printf("\n");
}
}

OUTPUT
Enter no. of files:2
Enter file name:abc
Enter starting block:2
Enter no.of blocks:5
Enter block numbers:1 2 3 4 5
Enter file name:xyz
Enter starting block:1
Enter no.of blocks:3
Enter block numbers:6 7 8
File start size block
abc 2 5 1--->2--->3--->4--->5
xyz 1 3 6--->7--->8

Department of Artificial Intelligence & Machine Learning, BIT Page 2

You might also like