The greatest mistake you can make in life is to be continually fearing you will make one

Thursday 20 May 2010

Questions on Command Line Arguments

  1. What is command line argument?
  2. Are variables argc and argv are local to main?
  3. Does there exist any way to make the command line arguments available to other functions without passing them as arguments to function?
  4. Is there any way to expand any wildcard characters present in the commandl ine arguments? If yes state that?
  5. What is the maximum length of command line arguments including space between adjacent arguments?
  6. What is 'c, and 'v' in argc and argv stand for?
  7. What is the output of the following program?
      #include < stdio.h >
    int main(int argc,char *argv[])
    {
        int i;
        argc=2;
        argv[0]="";
        argv[1]="I am a dog.Hope I am right";

        printf("Number of Arguments passed=%d\n",argc);
        for(i=0;i< argc;i++)
            printf("argv[%d]=%s\n",i,argv[i]);
        return;
    }
  8. Does the following program has any error or not?
    #include < stdio.h >
    int main(int argc,char *argv)
    {
        int x;
        x=sum(argv[1],argv[2]);
        printf("x=%d\n",x);
        return;
    }
    int sum(int x,int y)
    {
        return x+y;
    }
  9. What type is argv?
    A. char *
    B. int
    C. char **
    D. It's not a variable
     
  10. What does the argument count variable store?
    A. the number of arguments
    B. the number of arguments plus one
    C. the number of arguments minus one
    D. The total size of the argument array
     
  11. In what order do the two command line variables appear in the definition of main? A. Count then argument array
    B. Argument array then count
    C. They don't appear in the definition of main
    D. There is only one argument.
     
  12. What is argv[0]? A. The number of arguments to the program
    B. The name of the program
    C. The first argument to the program
    D. This syntax is illegal 

  13. What variables stores the number of arguments to a program?
    A. argc
    B. argv
    C count
    D. arglen





No comments:

Post a Comment