What's the difference with following codes:
Code #1: Using Binary Mode
int main()
{
std::fstream w("D:\\file.txt", std::ios::out | std::ios::binary);
char *p = "Hello World\r\nHi";
w.write(p, strlen(p));
// Close the file
w.close();
}
Code #2: Using Text Mode
int main()
{
std::fstream w("D:\\file.txt", std::ios::out);
char *p = "Hello World\r\nHi";
w.write(p, strlen(p));
// Close the file
w.close();
}
Does it matter whether I use binary or text mode in case of writing strings like this?