-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileAllocationTechnique(Indexed).cpp
More file actions
48 lines (42 loc) · 1.04 KB
/
FileAllocationTechnique(Indexed).cpp
File metadata and controls
48 lines (42 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <bits/stdc++.h>
using namespace std;
struct filetable
{
int nb;
int block[30];
char name[20];
} ft[30];
int main()
{
int n;
cout << "Enter the no of files" << endl;
cin >> n;
for (int i = 0; i < n; i++)
{
cout << "Enter the file name: " << endl;
cin >> ft[i].name;
cout << "Enter the no of blocks: " << endl;
cin >> ft[i].nb;
cout << "Enter the blocks: " << endl;
for (int j = 0; j < ft[i].nb; j++)
cin >> ft[i].block[j];
}
char target[20];
cout << "Enter the file name to be searched: " << endl;
cin >> target;
int i;
for (i = 0; i < n; i++)
if (strcmp(target, ft[i].name) == 0)
break;
if (i == n)
cout << "File not found" << endl;
else
{
cout << "File name\tNo of Blocks\tBlock nos" << endl;
cout << ft[i].name << "\t\t" << ft[i].nb << "\t\t";
for (int j = 0; j < ft[i].nb; j++)
cout << ft[i].block[j] << " ";
cout << endl;
}
return 0;
}