file_allocation_simulation
file_allocation_simulation
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_BLOCKS 10
typedef struct {
int startBlock;
int totalBlocks;
} Sequential;
typedef struct {
int *indexBlocks;
int numIndexBlocks;
} Indexed;
typedef struct {
int *nextBlock;
int totalBlocks;
} Linked;
// Function to display the Sequential Allocation strategy
printf("Sequential Allocation:\n");
printf("Indexed Allocation:\n");
printf("\n");
printf("Linked Allocation:\n");
printf("\n");
}
// Simulate file allocation with sequential allocation strategy
printf("Enter the start block and the total number of blocks for sequential allocation:\n");
sequentialAllocation(file);
int numBlocks;
scanf("%d", &numBlocks);
file->numIndexBlocks = numBlocks;
scanf("%d", &file->indexBlocks[i]);
indexedAllocation(file);
scanf("%d", &totalBlocks);
file->totalBlocks = totalBlocks;
scanf("%d", &file->nextBlock[i]);
linkedAllocation(file);
int main() {
int choice;
Sequential sequentialFile;
Indexed indexedFile;
Linked linkedFile;
while (1) {
printf("4. Exit\n");
printf("Enter your choice: ");
scanf("%d", &choice);
switch (choice) {
case 1:
allocateSequential(&sequentialFile);
break;
case 2:
allocateIndexed(&indexedFile);
break;
case 3:
allocateLinked(&linkedFile);
break;
case 4:
printf("Exiting...\n");
exit(0);
default:
return 0;