Comment
Comment by lasagnaphil
This code, which is clearly undefined behavior (because of dangling pointer), outputs the number 2, which is very worrisome.
I would recommend not using this for educational purposes yet; it could mislead students about pointer usage.