As I posted in comments:
*instruction = strtok(command, " ,.-");
*parameter_1 = strtok(NULL, " ,.-");
*parameter_2 = strtok(NULL, " ,.-");
should be relaced with
instruction = strtok(command, " ,.-");
parameter_1 = strtok(NULL, " ,.-");
parameter_2 = strtok(NULL, " ,.-");
Also sizeof(instruction)
doesn't return number of characters( it's not an array) but size of pointer to char (that's what instruction, param_1, param_2 really are) on your machine.
As answer to OP comment:
write()
or fwrite()
work on bytes, without checking its meanings so they don't stop on '\0'
.
fprintf()
, fputs()
are prepared to work on strings so they check for '\0'
char to stop.