This code does not give me the expected data in mystr, I get "Unhandled exception at 0x012D2CE3 in Project1.exe: 0xC0000005: Access violation reading location 0x00000000." instead.
#include <iostream>
#include <string>
int main(void)
{
std::string mystr;
// the '=' is actually a function that probably
// invokes dynamic allocation
mystr = "aB";
// print each character, no more, no less
for ( char x : mystr ) {
std::cout << x << '\n';
}
return 0;
// the destructor of mystr takes care of deallocation
}