This is the easy way to do it!
Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, char* argv[])
{
int i;
for (i = 0; i < argc, ++i)
system(argv[i]);
return 0;
}
Your code has a number of bugs. It uses gets and using scanf with %s and no
field specifier is just as bad. You should use fgets.
command[3] should be command[3][MAX_CMD_SIZE]
If I'm correct the best way to do this is to avoid the 2D array with something
like this
Code:
char command[MAX_CMD_SIZE];
while(fgets(comand, sizeof command, stdin) != NULL) {
printf("Enter command EOF to quit: ");
fflush(stdout);
system(command);
}