Your programme already crashes on the
cout << "op = " << op << endl;
line because there is an overload of the <<
operator for char*
that interprets them as a pointer to the initial element of a 0-terminated character array and prints the characters before the next 0-byte out, thus needing to dereference the pointer. But you initialised op
to be a null pointer, hence dereferencing it invokes undefined behaviour, often resulting in a crash (segmentation fault).
Casting op
to a different pointer type, e.g. a void*
cout << "op = " << static_cast<void*>(op) << endl;
would make that line work and print an implementation-defined representation of a null pointer.
You would then still have undefined behaviour (and most likely a crash) on the next line, where you explicitly dereference op
.