this code does not work....
plz help......
void breaker()
{
long int temppos = 0,pos = 0;
int n = 0;
char choice =' ';
char file[20] = "input.zip" ;
char filename[2][30];
strcpy(filename[0],file);
strcpy(filename[1],filename[0]);
strcat(filename[1],"1");
ifstream infile(filename[0],ios::binary);
infile.seekg(0, ios::end);
pos=infile.tell g();
do
{
cout<<" file size in kb : "<<(float)p os/1024;
cout<<"\nenter number files to be broken into: ";
cin>>n;
temppos=pos/n;
cout<<temppos<< "\n do you want to continue?..pres s q to re-enter number of
files..or any other key to continue..";
cin.get(choice) ;
}while(choice== 'q');
int ctr=0;
ofstream outfile(filenam e[1],ios::binary);
infile.seekg(0, ios::beg);
char byte;
infile.read(&by te,sizeof byte); //read and write functions used for working
on data the "binary" way.
char ext='1';
for(int i=0;i<n;i++)
{
ext++;
ctr=0;
while(ctr<tempp os) //temppos = pos/n..in line 31
{
outfile.write(& byte, sizeof byte);
infile.read(&by te, sizeof byte);
ctr++;
}
outfile.close() ;
strcpy(filename[1],filename[0]);
strcat(filename[1],&ext);
outfile.open(fi lename[1],ios::binary);//this line was the culprit..
}
outfile.close() ;
infile.close();
}
plz help......
void breaker()
{
long int temppos = 0,pos = 0;
int n = 0;
char choice =' ';
char file[20] = "input.zip" ;
char filename[2][30];
strcpy(filename[0],file);
strcpy(filename[1],filename[0]);
strcat(filename[1],"1");
ifstream infile(filename[0],ios::binary);
infile.seekg(0, ios::end);
pos=infile.tell g();
do
{
cout<<" file size in kb : "<<(float)p os/1024;
cout<<"\nenter number files to be broken into: ";
cin>>n;
temppos=pos/n;
cout<<temppos<< "\n do you want to continue?..pres s q to re-enter number of
files..or any other key to continue..";
cin.get(choice) ;
}while(choice== 'q');
int ctr=0;
ofstream outfile(filenam e[1],ios::binary);
infile.seekg(0, ios::beg);
char byte;
infile.read(&by te,sizeof byte); //read and write functions used for working
on data the "binary" way.
char ext='1';
for(int i=0;i<n;i++)
{
ext++;
ctr=0;
while(ctr<tempp os) //temppos = pos/n..in line 31
{
outfile.write(& byte, sizeof byte);
infile.read(&by te, sizeof byte);
ctr++;
}
outfile.close() ;
strcpy(filename[1],filename[0]);
strcat(filename[1],&ext);
outfile.open(fi lename[1],ios::binary);//this line was the culprit..
}
outfile.close() ;
infile.close();
}
Comment