Sometimes, you may want to cut up files to make them transportable by floppy disk. I'm trying to write a program to do this, but it's not working, as usual :P Here's what I've got :
Code:
void cut(char* filename, int filesizes)
{
clrscr();
fin.open(filename, ios::in | ios::nocreate);
if(!fin)
{
t("File not found. Exiting program...");
Sleep(1500);
exit(EXIT_SUCCESS);
}
string fileout = "";
int counter = 0;
int counter2 = 0;
char temp[1];
while(!fin.eof())
{
counter++;
counter2 = 0;
fin >> temp[0];
fileout += filename;
fileout += ".";
fileout += counter;
fileout += ".rps";
fout.open(fileout.c_str(), ios::out);
while(counter2 < 1024*filesizes)
{
if(fin.eof())
{
fin.close();
fout.close();
exit(EXIT_SUCCESS);
}
cout << "1, ";
fout << temp[0];
counter2++;
}
fout.close();
cout << "ONE FILE WRITTEN ! --------------------" << endl;
Sleep(1000);
}
}
As you can see, I annotated it to see what happens, but I get no files written, and I get this continuing past the EOF...
If I explain my code : the user types in a filename, and a filesize for each of the smaller files to be. This size is in kilobytes, which is why I write out 1024 times this number, as I write out a byte at a time. Void t is simply a typewriter effect for cout. It's probably something I've missed, but I can't see it.
Thanks for your help.