The question I have is that I want to create a file with any file format uptill .txt and wordpad this code is Ok, Butt when I try it for .docx or .pdf or .exe files the error occures in opening new created file.

I means that while opening the older test.docx it open as in routine while opening newly created .docx or others, an error occurs that "Word found unreadable content in file".

and in case of .exe file the error occured is "The version of file is not compatible with window you are running ".

The program is terminated successfully and the size of new file obtained is similar to previous one from where we read the problem comes in opening new file

The code I tried is:



#include <iostream;
#include<fstream;
using namespace std;
#include<string;

int main()
{
string line;
ifstream in;
in.open("test.docx",ios_base::binary);
ofstream out;
out.open("test1.docx",ios_base::binary);
if (in.is_open())
{
while ( !in.eof() )
{
getline(in,line);
out<<line;
cout<<line;
}


}
out.close();
in.close();

system("PAUSE");
return (0);
}</pre>


Any help is appreciated.

Thanks.