Hmm... This is indeed very interesting idea.
Wonder how did you do it. (share your code :D)
My first guess was to open the file in ios::app | ios::binary, allocate shit loads of memory into char* and then write it into file:
Code
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
size_t size;
string filename;
cin >> filename >> size;
ofstream file(filename, ios::app | ios::binary);
char* p = (char*)malloc(size*sizeof(char));
file << p;
free(p);
}
Tho it doesn't seem like a good idea, because it limited by RAM.
Second guess would be to allocate 1MB of ram and write 1 by one megabyte:
Code
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
size_t size;
string filename;
cout << "Enter file name: ";
cin >> filename;
cout << "Enter size in MB: ";
cin >> size;
ofstream file(filename, ios::app | ios::binary);
char* p = (char*)malloc(1048576*sizeof(char)); //Get 1 megabyte
while(size != 0)
{
file << p;
--size;
}
free(p);
}
Much more RAM friendly.
Can anyone think of better idea? :D