In short, is there any way I can take in a char *input
into a function and modify its original memory address without using something like memcpy
from string.h?
Yes, you can. Your function modifyCharArray
is doing the right thing. What you are seeing is caused by that fact that
char *test = "Bad";
creates "Bad"
in read only memory of the program and test
points to that memory. Changing it is cause for undefined behavior.
If you want to create a modifiable string, use:
char test[] = "Bad";