Hello,
I need to know how the get the integer value of a byte and vice versa.
I want to get the integer value from a byte read from a binary file.
I also want to convert the integer value back into a byte value for write.
Below I have code where the current byte is read into the variable 'byte". I am basically copying one file to the other.
Thanks.
#include <fstream.h>
#include <iomanip.h>
int main()
{
int ind, tot;
unsigned char byte;
ifstream infile("inputfile.dat", ios::in | ios::binary);
ofstream outfile("outputfile.dat", ios::binary );
for (!infile)
{
infile.read( byte, 1 );
outfile.write( byte, 1 );
return 0;
}
}