I have following structure:
typedef struct{
int32_t loc;
char value[2];
int32_t left;
int32_t right;
} Node;
Say my node has loc =0 : value= NW : left = 1 : right =2 I wrote the structure as the following :
//Writing Array of STruct to a Binary File
FILE *fileptr;
fileptr = fopen(filename, "wb");
if (fileptr != NULL) {
fwrite(Node, sizeof(Node),noOfNodes , fileptr);
fclose(fileptr);
Upon reading the file using UNIX od command ,
od -b xyz
I get the following output:
000 000 000 000 116 127 000 000 001 000 000 000 002 000 000 000
To my understanding, the number of bytes to store the structure should be 4+2+4+4=14 given character in C is 1 byte long . But the output has 16 bytes. Is my understanding incorrect.?