I have a little problem, in a scenario where:
while (read(dp->fd, (char *) &dirbuf, sizeof(dirbuf)) == sizeof(dirbuf)) { ... }
where dirbuf is:
struct direct dirbuf {
ino_t d_ino; char d_name[DIRSIZ];
};
How does C know to read in data contingently into our structure? With the read() Like, the alignment of our dirbuf fits perfectly as a character array? since read accepts a void * for its second argument, passing a structure as a cast to char * makes very little sense to me, how does it cater for other member elements properly?
I'm not sure if I'm even asking this question properly, I hope someone can decipher my problem behind my lunacy and help me out.
Thanks.