-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path6b.c
More file actions
56 lines (46 loc) · 1017 Bytes
/
6b.c
File metadata and controls
56 lines (46 loc) · 1017 Bytes
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
49
50
51
52
53
54
55
56
#include <stdio.h>
#include <string.h>
struct fileTable
{
char name[20];
int nob, blocks[30];
} ft[30];
int main(int argc, char const *argv[])
{
int i, j, n;
char s[20];
printf("\nEnter no. of files: ");
scanf("%d", &n);
for (i = 0; i < n; i++)
{
printf("\nEnter filename %d: ", i + 1);
scanf("%s", ft[i].name);
printf("\nEnter no. of blocks in file %d: ", i + 1);
scanf("%d", &ft[i].nob);
printf("\nEnter the blocks of the file: ");
for (j = 0; j < ft[i].nob; j++)
{
scanf("%d", &ft[i].blocks[j]);
}
}
printf("\nEnter the file name to be searched: ");
scanf("%s", s);
for (i = 0; i < n; i++)
{
if (strcmp(s, ft[i].name) == 0)
break;
}
if (i == n)
printf("\nFile not found.\n");
else
{
printf("\nFile Name\tNo. of Blocks\tBlocks Occupied");
printf("\n%s\t\t%d\t\t", ft[i].name, ft[i].nob);
for (j = 0; j < ft[i].nob; j++)
{
printf("%d->", ft[i].blocks[j]);
}
printf("\n");
}
return 0;
}