It is hard to believe that this code did not crash MATLAB. The issues:
char *code; <-- This is an uninitialized pointer ...
input = mxGetPr(prhs);
*code = mwe(input); <-- this copies a char into the garbage address (should have crashed MATLAB here)
plhs = mxCreateString(code); <-- Attempts to create a MATLAB char array from the bytes at that garbage address
That mxCreateString( ) call could easily have crashed MATLAB as well. If you want to copy characters into a pointer, then you need to allocate that pointer first. E.g.,
code = mxMalloc(2);
code = mwe(input);
code = '\0'; /* Null terminate the string */
It is not really clear what your ultimate intent is passing a double pointer into mwe and getting a char passed back, so I can't give you any advice there unless you give more details.