Click here to Skip to main content
16,007,885 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
JokeRe: Please Help me any body......... Pin
CPallini17-Sep-08 10:14
mveCPallini17-Sep-08 10:14 
AnswerRe: Please Help me any body......... Pin
Mark Salsbery17-Sep-08 6:19
Mark Salsbery17-Sep-08 6:19 
GeneralRe: Please Help me any body......... Pin
CPallini17-Sep-08 10:17
mveCPallini17-Sep-08 10:17 
GeneralRe: Please Help me any body......... Pin
Mark Salsbery17-Sep-08 10:25
Mark Salsbery17-Sep-08 10:25 
AnswerRe: Please Help me any body......... Pin
Hamid_RT17-Sep-08 8:30
Hamid_RT17-Sep-08 8:30 
QuestionNotifying Parent Dialog about the child control changes Pin
Vikas_12317-Sep-08 1:46
Vikas_12317-Sep-08 1:46 
Questioncopy content 2 file.txt ==> output.txt Pin
aa_zz17-Sep-08 1:12
aa_zz17-Sep-08 1:12 
AnswerRe: copy content 2 file.txt ==> output.txt Pin
enhzflep17-Sep-08 2:45
enhzflep17-Sep-08 2:45 
Not quite sure what your question is.... I've tried your code, and it does indeed copy the contents of a.txt and b.txt to c.txt

If I have \r\n in the input file, it is copied. If I do not have it, it's not copied. The code functions as it seems it should. What were you expecting, may I ask?

Also, have you tried looking at the text files with a hex-editor? Some text editors automatically insert \r\n at the end of the file when you save it, even if you didn't want them there. E.g Code::Blocks editor.

Also, if you put the line
using namespace std;
up in the top of your code somewhere, you can avoid having to type std:: all over the place.
Here's the code I tried.
#include <iostream>
#include <fstream>

using namespace std;

bool copyFile (const char SRC[], const char INPUT2[], const char DEST[])
{
    ifstream src; // the source file
    ifstream input2;
    ofstream dest; // the destination file
    src.open (SRC, ios::binary); // open in binary to prevent jargon at the end of the buffer
    input2.open(INPUT2, ios::binary);
    dest.open (DEST);//, std::ios::binary); // same again, binary

    if (!src.is_open() || !dest.is_open())
        return false; // could not be copied

    dest << src.rdbuf (); // copy the content
    dest << input2.rdbuf();

    dest.close (); // close destination file
    src.close (); // close source file

    return true; // file copied successfully
}

int main(int argc, char* argv[])
{
    if (!copyFile ("a.txt", "b.txt", "c.txt"))
        cout << "File could not be copied successfully";
    else
        cout << "File copied successfully!";

    cin.get (); // pause for input

    return 0;
}

QuestionString Convert Pin
si_6917-Sep-08 0:53
si_6917-Sep-08 0:53 
AnswerRe: String Convert Pin
toxcct17-Sep-08 0:59
toxcct17-Sep-08 0:59 
GeneralRe: String Convert Pin
CPallini17-Sep-08 2:58
mveCPallini17-Sep-08 2:58 
GeneralRe: String Convert Pin
toxcct17-Sep-08 3:05
toxcct17-Sep-08 3:05 
GeneralRe: String Convert Pin
PJ Arends17-Sep-08 9:53
professionalPJ Arends17-Sep-08 9:53 
GeneralRe: String Convert Pin
toxcct17-Sep-08 9:59
toxcct17-Sep-08 9:59 
GeneralRe: String Convert Pin
PJ Arends17-Sep-08 10:08
professionalPJ Arends17-Sep-08 10:08 
JokeRe: String Convert Pin
toxcct17-Sep-08 10:15
toxcct17-Sep-08 10:15 
AnswerRe: String Convert Pin
Hamid_RT17-Sep-08 8:25
Hamid_RT17-Sep-08 8:25 
QuestionInclude file Pin
Tomas(cz)17-Sep-08 0:46
Tomas(cz)17-Sep-08 0:46 
AnswerRe: Include file Pin
Cedric Moonen17-Sep-08 0:50
Cedric Moonen17-Sep-08 0:50 
AnswerRe: Include file Pin
Matthew Faithfull17-Sep-08 1:05
Matthew Faithfull17-Sep-08 1:05 
QuestionGDI+ code doesn't work as expected Pin
followait17-Sep-08 0:36
followait17-Sep-08 0:36 
Questiontypedef with multiple type-declarations Pin
DaveyM6917-Sep-08 0:30
professionalDaveyM6917-Sep-08 0:30 
AnswerRe: typedef with multiple type-declarations Pin
Cedric Moonen17-Sep-08 0:44
Cedric Moonen17-Sep-08 0:44 
GeneralRe: typedef with multiple type-declarations Pin
DaveyM6917-Sep-08 1:02
professionalDaveyM6917-Sep-08 1:02 
AnswerRe: typedef with multiple type-declarations Pin
Iain Clarke, Warrior Programmer17-Sep-08 0:56
Iain Clarke, Warrior Programmer17-Sep-08 0:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.