Hi I wanted to know if it's possible to read a byte from a binary file with "fstream" and then change that byte and write it back. I tried this code but it didn't work and nothing happens but I'm sure it reads correctly.
file.open(path, ios::in|ios::out|ios::binary|ios::ate);
file.seekg(0, ios::end);
int size=file.tellg();
file.seekg(0,ios::beg);
char buffer;
for(int i=0;i<size;i++)
{
file.read((char*)&buffer,sizeof(char));
buffer=(buffer+7)%256;
file.write((char*)&buffer, sizeof(char));
}
should I take the file pointer one byte back after reading like this:
file.seekg(-1, ios::cur);
Thanks in advance.