So I am writing my own custom FTP client for a school project. I managed to get everything to work with the swarming FTP client and am down to one last small part...reading the .part files into the main file. I need to do two things. (1) Get this to read each file and write to the final file properly (2) The command to delete the part files after I am done with each one.
Can someone please help me to fix my concatenate function I wrote below? I thought I had it right to read each file until the EOF and then go on to the next.
In this case *numOfThreads is 17.  Ended up with a file of 4742442 bytes instead of 594542592 bytes.  Thanks and I am happy to provide any other useful information.
EDIT: Modified code for comment below.
    std::string s = "Fedora-15-x86_64-Live-Desktop.iso";
    std::ofstream out;
    out.open(s.c_str(), std::ios::out);
    for (int i = 0; i < 17; ++i)
    {
            std::ifstream in;
            std::ostringstream convert;
            convert << i;
            std::string t = s + ".part" + convert.str();
            in.open(t.c_str(), std::ios::in | std::ios::binary);
            int size = 32*1024;
            char *tempBuffer = new char[size];
            if (in.good())
            {
                    while (in.read(tempBuffer, size))
                            out.write(tempBuffer, in.gcount());
            }
            delete [] tempBuffer;
            in.close();
    }
    out.close();
    return 0;
 
    