strcat
does not support formatting strings, it just does concatenation. Moreover, your use of the extra pair of parenthesis cause the C compiler to parse this as a comma operator, and not as arguments passed to the function.
That is, strcat((char*)cmdargs, ("%s ", tokens[i]));
will result in a call strcat((char*)cmdargs, tokens[i]);
as the comma operator invoke side-effect of all expression, but return the last value.
If you want to use strcat
, you should write:
strcat((char*)cmdargs, " ");
strcat((char*)cmdargs, tokens[i]);
The same thing apply to the strcpy
function call too.