My first time working with binary files, and I have pieces of hair in my hands. Anyway, I defined the following:
unsigned int cols, rows;
These variables can be from 1 to 500. When I get them in a binary, I do this:
myFile.write(reinterpret_cast<const char *>(&cols), sizeof(cols)); myFile.write(reinterpret_cast<const char *>(&rows), sizeof(rows));
When I get back to read the file, at cols = 300 , I get this as a result:
44 1 0 0
Can someone explain to me why I get this result? I canβt say that something is wrong there, because I honestly consider it to those who do not understand things. What I would like to do is save the value, as it is, in the file, so that when I read it, I also get this. And maybe I know, I just don't know that.
I would like to get some explanation of how this works and how to get the data that I read.
source share