Tuesday, 3 March 2020

Chapter 11 // Exercise 9 - Principles & Practice Using C++

In this exercise I am using Visual Studio Community 2017 and the header file "std_lib_facilities.h" which can be found here:

http://www.stroustrup.com/Programming/PPP2code/std_lib_facilities.h

Chapter 11 // Exercise 9

Split the binary I/O program from section 11.3.2 into two; one program that
converts an ordinary text file into binary and one program that reads binary
and converts it to text. Test these programs by comparing a text file with
what you get by converting it to binary and back.
When just running the code given in the book on a random file, I noticed that when reading it out to a new file, it cut off the last two characters. They weren't special ones just 'e' and '.'...After staring at the code and the book for a good 15 minutes I realised that I truly am an idiot because the program in the book is designed to read in integers...

After changing int to char it worked as expected, however I'm now wondering what was so different about 'e' compared to the other letters.




No comments:

Post a Comment