Sadly, the code YOU wrote is suboptimal. It doesn't check for bad pointers, has no comments, doesn't take memory corruption into consideration, and assumes the replacement character is not '\0'.
You would get a C- if I graded your test.
Now you'll argue that it's just a test, but the fact is your best work should not come only when under unexpected scrutiny, as it does with impromptu tests, it should be a mental process that is not bypassed for any reason.
In this case you've thought about it for weeks and still botched it.
Kudos for trying. We'll call you if we are interested.
You would get a C- if I graded your test.
Now you'll argue that it's just a test, but the fact is your best work should not come only when under unexpected scrutiny, as it does with impromptu tests, it should be a mental process that is not bypassed for any reason.
In this case you've thought about it for weeks and still botched it.
Kudos for trying. We'll call you if we are interested.