Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it safe to print 0 to a file?

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.

like image 581
Jeroen Avatar asked Dec 26 '22 18:12

Jeroen


1 Answers

Yes, you can write 0 to a file. To close it, just close the file handle.

like image 194
Benjamin Trent Avatar answered Jan 02 '23 15:01

Benjamin Trent