C Programming - Command Line Arguments - Discussion

Discussion Forum : Command Line Arguments - Find Output of Program (Q.No. 11)
11.
What will be the output of the program in Turbo C?
#include<stdio.h>

int main(int argc, char *argv, char *env[])
{
    int i;
    for(i=1; i<argc; i++)
        printf("%s\n", env[i]);
    return 0;
}
List of all environment variables
List of all command-line arguments
count of command-line arguments
Error: cannot have more than two arguments in main()
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
15 comments Page 2 of 2.

Janu said:   1 decade ago
What is environment variables?

Meenu said:   1 decade ago
Environment variable means?

Babazka said:   1 decade ago
Wikiok is right. None of provided answers is correct. Also, argv should be declared as char *argv[] or char **argv, not char *argv.

Wikiok said:   1 decade ago
"argc": how many arguments are in the char *argv[] array. So argc can not be used for the environment array.

char *env[] : http://www.gnu.org/s/libc/manual/html_node/Program-Arguments.html (Only in UNIX).

Ajit said:   1 decade ago
Till now I thought main () functn takes 2 arguments?.


Post your comments here:

Your comments will be displayed after verification.