#include <stdio.h>
int main(int argc, char *argv[])
{
int counter;
for(counter=0; counter<argc; counter++)
printf("argv[%2d]: %s\n",counter,argv[counter]);
return 0;
}
Output
sh-4.2$ ./main Hello world "how are you?"
argv[ 0]: ./main
argv[ 1]: Hello
argv[ 2]: world
argv[ 3]: how are you?
Consider the output
./main, Hello, and world are the single word argument while "how are you?" is multiple words arguments, to pass multiple words in command line, we can enclose them in double quotes.
Program:
Output
Consider the output
./main, Hello, and world are the single word argument while "how are you?" is multiple words arguments, to pass multiple words in command line, we can enclose them in double quotes.
need an explanation for this answer? contact us directly to get an explanation for this answer