I'm trying to get successive bytes to print on the screen for the file that I'm reading. The file that is being read in a .vdi file and I'm trying to display the size of the virtual drive in a printf format.
How can I display the integer values of the read in byte values from the file?
I'm still kind of fuzzy on how C works with the printf function. My code:
void get_file_size(u32 fd) {
u8* HDDsize = (u8 *)malloc(8);
if(HDDsize == NULL) {
printf("Memory not allocated!");
}
lseek(fd,DRIVE_SIZE,SEEK_SET);
read(fd,HDDsize,8);
printf("The file system size is: %lli\n",
HDDsize[7]+HDDsize[6]+HDDsize[5]+HDDsize[4]+
HDDsize[3]+HDDsize[2]+HDDsize[1]+HDDsize[0]);
free(HDDsize);
}