Reputation: 16865
Is it safe to print 0 (as unsigned char) into a file? Will that mess up (might the filesystem rely on NULL being file termination? )
I am using a std::ofstream
object to write to the file.
Upvotes: 4
Views: 132
Reputation: 39
It's just an ASCI character and eof() does'nt take 0 as a null character
Upvotes: 2
Reputation: 3995
You can write anything to the file, as long as you don't assign 0 to a pointer/variable in your code.
Upvotes: 2
Reputation: 7566
Yes, you can write 0
to a file. To close it, just close the file handle.
Upvotes: 4
Reputation: 423
You can write whatever you want to the file, the characters you send are interpreted into the specific character encoding of that file.
Only ofstream:close() will close a file
Upvotes: 2