Programming Language : C
I'd like to put my program in a infinite loop controlled by command line arguments..
I mean, unless I enter "quit" it should keep on executing based upon the arguments I enter to do..
Programming Language : C
I'd like to put my program in a infinite loop controlled by command line arguments..
I mean, unless I enter "quit" it should keep on executing based upon the arguments I enter to do..
Try this:
#include <stdio.h>
int main(int argc,char *argv[]);
{
char cmd = '\0';
char quit = 0;
while(quit==0) {
cmd = fgetc(stdin);
switch(cmd) {
case 'q':
{
quit =1;
break;
}
// process other cases.
}
}
fprintf(stdout,"Quiting\n");
}
If I am not mistaken you can use the following function : system() in stdlib.h
where the syntax is as follows:
int system(const char *command);
here you can pass any shell command as a string argument