Posted September 1, 20186 yr 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?
September 1, 20186 yr 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, 20186 yr by Ahmad_k
Create an account or sign in to comment