Hey;
I am having problem with the read and write functions in fstream. They need to have a const char * to read or write from/to buffer. I need to work with integers.
Here what happens:
for(int i = 0; i < numberOfValues; i++)
{
int random = rand() % 100;
cout << random;
file.write((char *)&random, sizeof(int));
int read;
file.read((char *)&read, sizeof(int));
cout << read;
}
This code writes a value and tries to read it back. But the results don't match. What is the problem, and what is the solution of course :)