Comments on Linux C Programming tutorial part 22 - Accessing command line arguments within C program
In the previous tutorial, we discussed multiple concepts related to pointers in C programming language. One of the concepts we discussed was an array of pointers.
1 Comment(s)
Add comment
Comments
By: Aurel Serban
#include <stdio.h>int main(int argc, char *argv[]) {// find out the command line arguments & and their number int k = 0; while( w[k] != NULL ) { puts(argv[k]); k++; } printf("%d arguments found.\n", k); }With this simple routine we can find out the arguments' count from the command line whenwe call a C program. So what about argc? Is it redundant parameter of main()?Thank you.