I have the following C ++ code snippet.
int arr[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
ofstream output("Sample.txt", ios::out | ios::binary);
for(int i = 0; i < 10; i++)
{
output<<arr[i];
}
Now Sample.txt looks like this:
12345678910
Isn't "Sample.txt" supposed to be in binary format? Why does it not convert everything to binary when I opened the stream in binary mode. What should I do if I need the binary nature of each element of the array and then print it in a file.
source
share