Code:
#include <fstream>
#include <iostream>
#include "vars.h"
using namespace std;
int main(void)
{
ifstream inFiles;
ofstream datFile;
char *buffer;
datFile.open("thps2.dat", ios::binary | ios::ate);
int test;
for(int i = 0; i < 67; i ++)
{
inFiles.open(fileNames[i], ios::binary | ios::ate);
inFiles.seekg(0, ios::end);
test = inFiles.tellg();
buffer = new char[test];
inFiles.seekg(0, ios::beg);
inFiles.read(buffer, test);
cout<<test;
datFile.write(buffer, test);
delete[] buffer;
inFiles.close();
}
}
sizeof(buffer) is NOT the same as test. Buffer is not an array, it's a character pointer to the beginning of an array; sizeof(buffer) is the same as sizeof(char *) which is often 4 on 32-bit computer systems.
You also should seek to the file's end *after* you open it, not before.
The rest was just making your code proper C++.