Hello i will write for you an example code, explain it to you and really hope this helps you. the function's prototype is something like:
int system(const char* cmd);
#define MAX_CMN_LEN 100
int main(int argc, char *argv)
char cmd[MAX_CMN_LEN] = "", **p;
if (argc < 2) /*no command specified*/
fprintf(stderr, "Usage: ./program_name terminal_command ...");
for (p = &argv; *p; p++)
strcat(cmd, " ");
1). open up a terminal and compile the program
2). run it (for example in Ubuntu) ./program_name comman_name -anything - anything
example: ./a.out locale -a
this example prints all locales supported by my compiler which is gcc.
p is a poniter to pointer to char (like argv is)
p = &argv, points to -anything string
i cat all -anythings to my cmd string
i quit the loop when *p points to NULL
look at this: -> i will use this symbol to say points to (dont confuse it with right arrow selection operator).
argv -> program_name
argv -> command_name (in this example command name will be locale, but enter the command you want to check instead)
argv -> -anything (in this example -a, which is all locales)
argv -> NULL (in this example, this quits the loop)
ok thats it, i think.