473,386 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

code doesnt work ....plz help.

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.tellg();

do
{
cout<<" file size in kb : "<<(float)pos/1024;
cout<<"\nenter number files to be broken into: ";
cin>>n;
temppos=pos/n;
cout<<temppos<<"\n do you want to continue?..press q to re-enter number of
files..or any other key to continue..";
cin.get(choice);

}while(choice=='q');

int ctr=0;
ofstream outfile(filename[1],ios::binary);

infile.seekg(0,ios::beg);

char byte;

infile.read(&byte,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<temppos) //temppos = pos/n..in line 31
{
outfile.write(&byte, sizeof byte);
infile.read(&byte, sizeof byte);

ctr++;
}

outfile.close();
strcpy(filename[1],filename[0]);
strcat(filename[1],&ext);
outfile.open(filename[1],ios::binary);//this line was the culprit..
}

outfile.close();
infile.close();
}
Jul 19 '05 #1
3 2073
sachin bond wrote:
this code does not work....

plz help......

[SNIP]

For me it works. For further info please read:

http://www.parashift.com/c++-faq-lit...t.html#faq-5.8

--
WW aka Attila
Jul 19 '05 #2
This compiles but let it be known whether u are getting a compiling error or
u are not getting the expected results..
If so what is that you are expecting out of this program

Param
"sachin bond" <fl***********@hotmail.com> wrote in message
news:bj************@hotmail.com...
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.tellg();

do
{
cout<<" file size in kb : "<<(float)pos/1024;
cout<<"\nenter number files to be broken into: ";
cin>>n;
temppos=pos/n;
cout<<temppos<<"\n do you want to continue?..press q to re-enter number of files..or any other key to continue..";
cin.get(choice);

}while(choice=='q');

int ctr=0;
ofstream outfile(filename[1],ios::binary);

infile.seekg(0,ios::beg);

char byte;

infile.read(&byte,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<temppos) //temppos = pos/n..in line 31
{
outfile.write(&byte, sizeof byte);
infile.read(&byte, sizeof byte);

ctr++;
}

outfile.close();
strcpy(filename[1],filename[0]);
strcat(filename[1],&ext);
outfile.open(filename[1],ios::binary);//this line was the culprit.. }

outfile.close();
infile.close();
}

Jul 19 '05 #3
Param wrote:
This compiles but let it be known whether u are getting a compiling error or
u are not getting the expected results..
If so what is that you are expecting out of this program


Please don't top-post.

http://www.parashift.com/c++-faq-lit...t.html#faq-5.4

Do not top-post. In other words, don't type your reply above the
previous author's text. Even if top-posting seems "natural" or "obvious"
or "better," don't do it — it's not the comp.lang.c++ "way."
A: Top posting!
Q: What is the most irritating thing on Usenet?
-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.

Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: | last post by:
Hello, I hope someone will help me or I will have to dive from 11th floor. Why this --> test = @"Melanie "Jets" Riggs" doesnt work in asp? I need something like that and I dont know how to make it...
7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
17
by: tshad | last post by:
Many (if not most) have said that code-behind is best if working in teams - which does seem logical. How do you deal with the flow of the work? I have someone who is good at designing, but...
3
by: funfair | last post by:
Hi, I'm facing a strange problem in access 2003 i dont know how to solve it i have a code in VB which give an autonumber but in finanical new year it reset to 1 on new year it works in one form...
15
by: iwdu15 | last post by:
hi, i have these 2 code snippets: Public Sub ImRec(ByVal IM As IAccIm, ByVal Sender As IAccUser) Dim str As String = IM.GetConvertedText(DECODE) Dim temp As String = str temp =...
13
by: nigel.t | last post by:
Using linux <?php exec("/bin/tar -cvzf myfile.tgz /home/",$arrayout,$returnval); ?> or perhaps try it on your system and tell me if it does/doesnt and what your linux is? I've also tried
0
by: jmacduff | last post by:
Big question: How to enable edit/update commands to work when setting the sqldatasource select command from code behind. Details: I have a GridView using a sqldatasouce with the select and...
0
by: Juna | last post by:
I have been working in vs2003, but now started to work in vs2005 but the problem, I have simple web application not website, which work i mean open in browser when we press F5 or run the...
8
by: wastedhello | last post by:
ok. here are a list of things i cant fix. ive been trying for way to long now. 1. if more then 1000 values are told, will still continue with program. 2. if -max, min, average etc run, and 2...
5
by: slizorn | last post by:
hi, well this is the file i have to read into the system... <matrix> rows = 2 cols = 2 1 2 2 4 </matrix>
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.