Hello guyz, i need little help i created C++ program thats suppose to create binary files from hexa code in unsigned char variable, when i test it with 2 variables to create 2 files, it works perfect, but when i try to create 4 files from 4 variables, it doesn't work.
for example i have these variables like below
unsigned char data1[] = { /* Hexa Code */ }
unsigned char data2[] = { /* Hexa Code */ }
unsigned char data3[] = { /* Hexa Code */ }
unsigned char data4[] = { /* Hexa Code */ }
when i just remove any 2, it works, but when i want to run all 4, it doesn't work.
i am using ofstream mfile ("filename.exe", ios::out | ios::app | ios::binary); to create binary files. its working only for 2 files, not for other. i am not using any loop i have 4 ofstream openers, then i use write() and close() as well.
Kindly advise me what could be the reason behind this ??
waiting for kind response
Thanks
it could be anything... we really have to see your code to tell you what is wrong with it.
you probably don't need all those flags but they should not hurt anything. ofstream is already output, and app on a new file is not doing anything (it will on an existing file).
i mean,
..
ofstream ofs;
ofs.open(file1); //binary flag, whatever else you need...
ofs.write(data1, data1length); //been a while, whatever parameters for write...
ofs.close();
^^^ repeating something like that 4 times should do it.