Reputation: 327
I want to write some data to a binary file. I output a char array to a file like this
std::ofstream os;
os.open("myfile", std::ios::out | std::ios::binary);
os<<"A";
os.close();
or
char a[]="A";
File* file = fopen ("myfile","wb");
fprintf(file,"%s",a);
And in the end, does the file includes the '\0'?
In other words, the data of the file is 0x41 or 0x4100 in hexadecimal。
Upvotes: 0
Views: 85
Reputation: 141493
And in the end, does the file includes the '\0'?
No. Strings are printed excluding terminating zero byte.
Upvotes: 1