Solved. I didn't know the char type existed in signed and unsigned forms.
Knowing that, I only needed to add a function converting signed char to unsigned char.
Code:
#include <iostream>
#include <fstream>
#include <string>
#include <math.h>
#include <iomanip>
using namespace std;
ifstream::pos_type size;
char * cache;
unsigned char unsign(char in)
{
if (in>=0) return in;
else return in+256;
}
int readint(unsigned __int64 o=0)
{
unsigned int out=0;
for (int i=0; i<=3; i++)
{ out+=unsign(cache[i+o])*pow(256, i);}
return out;
}
main () {
ifstream infile ("in.scb", ios::in|ios::binary|ios::ate);
if (infile.is_open())
{
size = infile.tellg();
string brk; brk+=char(0x0D); brk+=char(0x0A);
cache = new char [size];
infile.seekg (0, ios::beg);
infile.read (cache, size);
infile.close();
cout << "SCB File read to memory:\n";
unsigned int version=readint(0), lines=readint(4), bytes=readint(8);
cout << setw(4) << setfill('0') << hex
<< "SCB version " << version << "\n"
<< lines << " lines\n"
<< bytes << " bytes\n";
ofstream outfile ("out.txt", ios::out|ios::trunc|ios::binary);
if (outfile.is_open())
{
for (int i=0xC, l=0; i<bytes+0xC && l<lines; i++)
{
if (cache[i]==0)
{ outfile << brk; l++;}
else
{ outfile << cache[i];}
}
outfile.close();
cout << "Transcription complete!\n";
}
else
cout << "Unable to open output file!\n";
delete[] cache;
}
else cout << "Unable to open input file\n";
cout << "\n";
system("PAUSE");
}