1.

Solve : Create a txt file in dos?

Answer»

If you have a FASTER processor, you can handle more data handling at once. Other than that, I don't think too much can be done.

The code:

Code: [Select]//Creates 500MB of filler

#include <fstream>
using namespace std;

int getSize();

int main()
{
for(LONG J = getSize(); j <= 524288000;)
{
ofstream file ("space.txt", ios::app);
for(int i = 0; i < 100; i++)
{
file << " ";
}
j = getSize();
}
}

int getSize()
{
unsigned long begin, end;
ifstream myfile ("space.txt");
begin = myfile.tellg();
myfile.seekg (0, ios::end);
end = myfile.tellg();
myfile.close();
return end-begin;
}if you have Python, here's an alternative:
Code: [Select]def makeempty(filename, size):
''' Make file called filename of size bytes '''
open(filename, "wb").write("\0" * size)
make_empty_file("empty",500)
this will create an "empty" file with "size" bytes. in above example, its 500 bytes. substitute appropriately for 500Mb



Discussion

No Comment Found