I need to call an external command in my C code. Let's say I need to call ls command but passing parameters could be variable. How can I do that?
I was planning to do it using sprtinf() but I rather go with char* string type.
so instead of using array and sprintf(buf, "ls %s -t ", filename);
I want to do it using char* i.e.
char* cmdstring = "/home/user1/cmd1 %s %d" // I know this is not valid but how can I do it using char* ?
but I'm not sure how I can change those parameters in char* as we can do in sprintf.
any idea is appreciated.