-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnions.cpp
More file actions
executable file
·45 lines (38 loc) · 809 Bytes
/
Copy pathUnions.cpp
File metadata and controls
executable file
·45 lines (38 loc) · 809 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
#include <iostream>
using namespace std;
struct dirEntry
{
uint8_t dirType;
int8_t fileName[9];
uint16_t lastBlockUsedBytes;
uint32_t actualBlockNumber;
};
struct directory
{
uint32_t prevBlock;
uint32_t nextBlock;
uint32_t firstUnusedBlock;
uint32_t fillerChar;
dirEntry dirEntries[31];
};
struct file
{
uint32_t prevBlock;
uint32_t nextBlock;
uint8_t fileData[504];
};
// IMP: If the structure is declared inside the Union, then the size of the union will be
// considered as ONE.
union block
{
directory directoryEntry;
file fileEntry;
};
int main()
{
cout << sizeof(directory) << endl;
cout << sizeof(file) << endl;
cout << sizeof(block) << endl;
cout << endl;
return 0;
}