I want to copy one image file to another new file. This is my method to do this:
    std::ofstream myOutpue;
    std::ifstream mySource;
    //int i = 0;
    mySource.open(ofn.lpstrFile, std::ios::binary);
    myOutpue.open("im4.jpg", std::ios::binary);
    char buffer;
    char bufferToSave[100];
    if (mySource.is_open())
    {
        //client->sendFilePacket(FileStates::START_SAVE, buffer, false,i);
        i++;
        while (!mySource.eof())
        {
            mySource >> std::noskipws >> buffer;
            myOutpue << buffer;
            //client->sendFilePacket(FileStates::CONTINUE_SAVE, buffer, false,i);
            i++;
        }
    }
    i++;
    //client->sendFilePacket(FileStates::END_SAVE, buffer, true,i);
    mySource.close();
    //myOutpue.close();
This method work correctly, but my problem is that i want to copy char/bit's and send it to another client. When i doing this by each char , that not work correctly so i want to make a bigger buffor(for example char t[512]) or something like that and copy them to new file.
I try to doing this like that:
    std::ofstream myOutpue;
    std::ifstream mySource;
    mySource.open(ofn.lpstrFile, std::ios::binary);
    myOutpue.open("im4.jpg", std::ios::binary);
    char buffer;
    char bufferToSave[100];
    if (mySource.is_open())
    {
        //client->sendFilePacket(FileStates::START_SAVE, buffer, false,i);
        i++;
        while (!mySource.eof())
        {
            if (i == 100)
            {
                for (int i = 0; i < 100; i++)myOutpue << bufferToSave[i];
                i = 0;
            }
            mySource >> std::noskipws >> buffer;
            bufferToSave[i] = buffer;
            //myOutpue << buffer;
            //client->sendFilePacket(FileStates::CONTINUE_SAVE, buffer, false,i);
            i++;
        }
    }
    i++;
    //client->sendFilePacket(FileStates::END_SAVE, buffer, true,i);
    mySource.close();
    myOutpue.close();
But i get image that i can't open.
So my question is how to read file to get more bits from it and that create me the same image as original.
 
     
     
     
    