I am trying to implement a distributed file system and for that I have to read files in chunks (files can be of any type image, audio, video, text, etc).
`typedef struct chunk_structure{
int chunk_id;
int is_last;
char file_name[100];
char buffer[2048];
//some other fields
}`
I am reading 2048 bytes from the file using fread copy it to a struct chunk_structure variable and pass it on to the data server. Data server stores each chunk to a different binary file using fwrite but while retrieving the value, though, I get some of the file contents, I also get some random characters.
Can someone please explain what could have gone wrong? or if can anyone suggest a different way of doing this.