C Programming - Command Line Arguments - Discussion

Discussion Forum : Command Line Arguments - Find Output of Program (Q.No. 6)
6.
What will be the output of the program (sample.c) given below if it is executed from the command line?
cmd> sample "*.c"
/* sample.c */
#include<stdio.h>

int main(int argc, int *argv)
{
    int i;
    for(i=1; i<argc; i++)
        printf("%s\n", argv[i]);
    return 0;
}
*.c
"*.c"
sample *.c
List of all files and folders in the current directory
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
22 comments Page 3 of 3.

Anu said:   1 decade ago
Can someone explain about the output of the above program ?

Sreepal V said:   1 decade ago
A command line argument is the
information that follows the program's name on the command line of the operating system. For
example, when you compile a program, you might type something like the following after the
command prompt,

program_name string1 string2 string3 ... (default syntax)

OR

"program_name" "string1" "string2" "string3" ...(correct syntax)


Post your comments here:

Your comments will be displayed after verification.