Hello,
copying from one file to another is a simple matter.
In C it's something like this:
int main(void)
{
FILE * fp1, * fp2 ;
int buff;
fp1 = fopen ("name", "rb");
fp2 = fopen ("name", "wb");
while ( (buff = fgetc(fp1)) != EOF)
{
fputc(buff, fp2);
}
}
I'm wondering how this is done in C++
My idea is this:
int main()
{
int buf;
ifstream fp_in("my.txt", ios_base::binary | ios_base::in );
ofstream fp_out("my_copy.txt", ios_base::binary | ios_base::out);
while (fp_in.read ( (char*) &buf, sizeof buf ))
fp_out.write ( (char*) &buf, sizeof buf );
}
I think this is very bad solution because of performance.
Can you suggest me any other way in C++ to achive this?
Thanks