Reputation: 329
I woud like to ask why i have to use &buffer instead of just buffer, why I am passing adress to reinterpret cast or type conversion. Thanks.
DWORD buffer;
std::ifstream openFile("xxxxx",std::ios::in|std::ios::binary);
std::ofstream writeFile("xxxxx",std::ios::out|std::ios::binary);
while(!openFile.eof())
{
openFile.read(reinterpret_cast<char*>(&buffer),sizeof(DWORD));
writeFile.write((char *)&buffer,sizeof(DWORD));
}
Upvotes: 0
Views: 1185
Reputation: 1547
Check out this pointers reference. What you have is a variable, prepending a&
to tells c++ that you want to refer to the address location of you data, (known as a pointer to the data). This is an effective way to create efficient code as you don't have to copy the data when you pass it to the function, you just tell the function where it is located so it can reference it as needed.
Cheers
Upvotes: 1