CodeExplorer Posted September 1, 2018 Posted September 1, 2018 Easy way to write chars to file? Tried http://www.java2s.com/Code/Cpp/File/Writeunsignedchartoafileandreaditback.htm ofstream out("D:\\block1"); out.write((char *) &block1Conv, sizeof block1Conv); out.close(); There is a problem: it will replace 0A with 0D0A How I can avoid the newline stuffs?
Ahmad_k Posted September 1, 2018 Posted September 1, 2018 (edited) By default ofstream treats the file as text file, so 0x0A will be transformed to 0x0d, 0x0a. You have to open you file in binary mode. ofstream out("D:\\block1", ios::binary); out.write((char *) &block1Conv, sizeof block1Conv); out.close(); Edited September 1, 2018 by Ahmad_k 1 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now