passing command line arguments while compiling c code code example
Example 1: command line arguments in c
int main( int argc, char *argv[] )
./a.out kiran kumar gun
./a.out is arg[0]
kirna is arg[1]
Example 2: read from command line c
#include <stdio.h>
int main(int argc, char **argv) {
for (int i = 0; i < argc; ++i) {
printf("argv[%d]: %s\n", i, argv[i]);
}
}
/*
[birryree@lilun c_code]$ ./a.out hello there
argv[0]: ./a.out
argv[1]: hello
argv[2]: there
*/