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;
using namespace std;

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


return (0);

Any help is appreciated.