code doesnt work ....plz help.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sachin bond

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


    }
  • White Wolf

    #2
    Re: code doesnt work ....plz help.

    sachin bond wrote:[color=blue]
    > this code does not work....
    >
    >
    >
    > plz help......[/color]
    [SNIP]

    For me it works. For further info please read:



    --
    WW aka Attila


    Comment

    • Param

      #3
      Re: code doesnt work ....plz help.

      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" <flirt4fun_143@ hotmail.com> wrote in message
      news:bjoqk5$3dg _002@hotmail.co m...[color=blue]
      > 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[/color]
      of[color=blue]
      > 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[/color]
      working[color=blue]
      > 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[/color]
      culprit..[color=blue]
      > }
      >
      >
      >
      > outfile.close() ;
      > infile.close();
      >
      >
      > }[/color]


      Comment

      • Kevin Goodsell

        #4
        Re: code doesnt work ....plz help.

        Param wrote:[color=blue]
        > 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
        >[/color]

        Please don't top-post.



        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.

        Comment

        Working...