I'm trying to write a string in binary.
Here is my code:
bool Database::createTable(string name, string content)
{
string *filePath = new string(*this->path + "/" + name + ".dt");
ifstream *checkFile = new ifstream(*filePath);
if(checkFile->good())
{
return false;
}
ofstream *file = new ofstream(*filePath, ios::binary);
file->write(content.c_str(), content.size());
file->close();
delete filePath;
delete checkFile;
delete file;
return true;
}
I would like to see something like that in a text editor:
6a6f 686e 0000 0000 0000 0000 1500 0000
1039 4099 b67f 0000 1c39 4099 b67f 0000
But I'm seeing plain text.
If I take out the ios::binary
, it outputs the same thing.
What am I misunderstanding?
Thanks.