Don't use strcmp
, it expects a null terminated characters sequence. Instead, use direct comparison:
if (last_char == ';') ...
Also, your code invokes undefined behavior in the strcat()
call. my_string
was initialized with a string literal, thus, you are not allowed to modify it, since the implementation is free to place it in read-only memory (and typically will do so).
You can declare it like this instead:
char mystring[12] = "C:/windows"; // space for one more char