I am writing to a file in C++ in append mode, the program which I am using for the same is:
#include <fstream>
void main()
{
ofstream f;
f.open("f.txt", ios::app);
f<<"\n Hello";
f.close();
}
Now the output which is getting printed in the output file is some thing junk...which I can't comprehend:
OUTPUT:
牐湩㩴
Please help me as to where am i going wrong??? I am working on linux.
The file which you are appending to has a BOM marker indicating it is UTF-16 encoded. Recreate the file using an editor which will not encode the file, or use a program to write it from scratch.
This is because you didn't specify a text encoding, and in the absence of explicit encoding markings, Windows just guesses. The most famous instance of this is Bush Hid The Facts
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.