Passing arguments to a C program from terminal
Have you ever wondered how some UNIX commands take arguments? It can be done very easily with C.
You can code the rm, cp, ect commands in no time. Here is a sample code which you can use to understand passing arguments.
int main(int argc, char* argv[]){
int i;
for(i = 0;i<argc; i++){
printf("%d: %s\n", i+1, argv[i]);
}
return 0;
}
argc is the number of arguments being passed in, and argv is a char pointer array which has the arguments.
Categories: OOP344