On my first programming lesson I could not figure up how to store some content with NULL bytes (such as a webpage) in C++ string and the teacher did not know it either.
This is the exact situation that I always liked to show my students, because it shows the power of abstractions, in this case the c++ string object, and the danger of making assumptions about data. And then, finally, showing them how it is very much possible, and it was designed into the library in order to accommodate such use cases. Basically, I used it as a tool to help them better understand the data representation of strings, as well as for them to learn something deeper about the c++ standard library.
Comments
On my first programming lesson I could not figure up how to store some content with NULL bytes (such as a webpage) in C++ string and the teacher did not know it either.
Did you ever figure it out?
This is the exact situation that I always liked to show my students, because it shows the power of abstractions, in this case the c++ string object, and the danger of making assumptions about data. And then, finally, showing them how it is very much possible, and it was designed into the library in order to accommodate such use cases. Basically, I used it as a tool to help them better understand the data representation of strings, as well as for them to learn something deeper about the c++ standard library.