Hello I have the following code:
I would like to understand what the third line does.
int number = 0;
file.read((char *)&number, sizeof(int));
the read function reads a block of 4 bytes from the file "file.data".
the first argument specifies where we want to save that block of data.
in what format is the data going to be saved in this variable?
(char *) reminds me of an array of chars(bytes). So the block will be in bytes?
and why is there an "&" after that? I tried without it but it didn't work.
the & is the address of the variable "number"
and then it takes this address and casts it to a sequence of bytes
I don't really understand this
thanks in advance