Thank you Sir for this solution. Your solutions are very easy that it really helped me to understand the logic behind each and every program in no-time.
Also i would like to say that "I was able to completely understand a total of 38 programs out of 50 which counts to 19-Slips in a span of mere 2 days just with help of your solutions".
I once find it difficult to solve but then your solutions turned-out a boon for my practicals.
Instead Of Doing File Allocation Problem using Linked List use Simple Array and Structure will help u to understand File Allocation easily.(below code help you to understand)
#include #include #include #include
typedef struct { char name[100]; int start,len; }ALLO;
ALLO f[100];
int counter=0;
int create_new_file(int vector[]) { int st,len,j; char fname[100];
printf("\n\tEnter The Name of File? "); scanf("%s",fname); printf("\n\tEnter Starting Block And Length of File :"); scanf("%d%d",&st,&len);
} int main() { int n,vector[100],i,ch; srand(time(NULL));
printf("How Many Blocks In a Disk?"); scanf("%d",&n);
for(i=0;i<n;i++) vector[i]=rand()%2;
do { printf("\n-----------------------------------------------------\n"); printf("\n1.Show Bit Vector\n2.Create New File\n3.Show Directory\n4.Delete File\n5.Exit\n\n\tEnter Your Choice?"); scanf("%d",&ch);
switch(ch) { case 1: printf("\nAvailable Bit Vectors Are :"); for(i=0;i<n;i++) printf("[ %d ]",vector[i]); break; case 2:create_new_file(vector); break; case 3:show_directory(); break; case 4:delete_file(vector); break; }
Thank you for sharing useful notes Sir
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThank you Sir for this solution.
ReplyDeleteYour solutions are very easy that it really helped me to understand the logic behind each and every program in no-time.
Also i would like to say that "I was able to completely understand a total of 38 programs out of 50 which counts to 19-Slips in a span of mere 2 days just with help of your solutions".
I once find it difficult to solve but then your solutions turned-out a boon for my practicals.
Its very discriptive and well structured
ReplyDeleteIt helped me a lot to undertand the logic
thank you so much
thank you so much sir.. :)
ReplyDeleteThank you Very Very much...
ReplyDeleteInstead Of Doing File Allocation Problem using Linked List use Simple Array and Structure will help u to understand File Allocation easily.(below code help you to understand)
ReplyDelete#include
#include
#include
#include
typedef struct
{
char name[100];
int start,len;
}ALLO;
ALLO f[100];
int counter=0;
int create_new_file(int vector[])
{
int st,len,j;
char fname[100];
printf("\n\tEnter The Name of File? ");
scanf("%s",fname);
printf("\n\tEnter Starting Block And Length of File :");
scanf("%d%d",&st,&len);
for(j=st;j%d",j,vector[j]);
if(j==(st+len)-1)
{
strcpy(f[counter].name,fname);
f[counter].start=st;
f[counter].len=len;
counter++;
}
}
else
{
printf("can't allocate file ...");
break;
}
}
}
int show_directory()
{
int i;
printf("FILE NAME START LENGTH\n");
for(i=0;i<counter;i++)
{
printf("%s %d %d\n",f[i].name,f[i].start,f[i].len);
}
}
int delete_file(int vector[])
{
char fname[100];
int i,flag,j;
printf("\n\tEnter File name to delete from block: ");
scanf("%s",fname);
for(i=0;i<counter;i++)
if(strcmp(fname,f[i].name)==0)
{
for(j=f[i].start;j<f[i].start+f[i].len;j++)
{
vector[j]=0;
}
break;
}
for(;i<counter;i++)
f[i]=f[i+1];
counter--;
}
int main()
{
int n,vector[100],i,ch;
srand(time(NULL));
printf("How Many Blocks In a Disk?");
scanf("%d",&n);
for(i=0;i<n;i++)
vector[i]=rand()%2;
do
{
printf("\n-----------------------------------------------------\n");
printf("\n1.Show Bit Vector\n2.Create New File\n3.Show Directory\n4.Delete File\n5.Exit\n\n\tEnter Your Choice?");
scanf("%d",&ch);
switch(ch)
{
case 1:
printf("\nAvailable Bit Vectors Are :");
for(i=0;i<n;i++)
printf("[ %d ]",vector[i]);
break;
case 2:create_new_file(vector);
break;
case 3:show_directory();
break;
case 4:delete_file(vector);
break;
}
}while(ch!=5);
}
same way u can do other Allocation method.
Saved my practical exams❤😁😇
ReplyDeleteHow execute the shell program..normal like c ??? Plzz send me d steps
ReplyDeleteHey,
ReplyDeleteThanks for sharing your knowledge with us
Pune University