Home / C Programming / Command Line Arguments :: General Questions

C Programming :: Command Line Arguments

  1. The maximum combined length of the command-line arguments including the spaces between adjacent arguments is

  2. A.
    128 characters
    B.
    256 characters
    C.
    67 characters
    D.
    It may vary from one operating system to another

    View Answer

    Workspace

    Discuss Discuss in Forum


  3. If the different command line arguments are supplied at different times would the output of the following program change?

     #include 
    
     int main(int argc, char **argv) 
     {  
         printf("%d\n", argv[argc]);   
         return 0;
     } 
    

  4. A.

    Yes

    B.

    No

    View Answer

    Workspace

    Discuss Discuss in Forum


  5. According to ANSI specifications which is the correct way of declaring main when it receives command-line arguments?

  6. A.
    int main(int argc, char *argv[])
    B.
    int main(argc, argv) 
    int argc; char *argv; 
    C.
     int main()
     {  
        int argc; char *argv; 
     } 
    D.

    None of above

    View Answer

    Workspace

    Discuss Discuss in Forum


  7. What do the 'c' and 'v' in argv stands for?

  8. A.
    'c' means argument control 'v' means argument vector
    B.
    'c' means argument count 'v' means argument vertex
    C.
    'c' means argument count 'v' means argument vector
    D.
    'c' means argument configuration 'v' means argument visibility

    View Answer

    Workspace

    Discuss Discuss in Forum


  9. 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 
    
      int main(int argc, int *argv) 
      {   
         int i;    
         for(i=1; i"%s\n", argv[i]); 
        return 0;
        }
    

  10. A.

    *.c

    B.

    "*.c"

    C.

    sample *.c

    D.

    List of all files and folders in the current directory

    View Answer

    Workspace

    Discuss Discuss in Forum


  11. What will be the output of the program (myprog.c) given below if it is executed from the command line?
    cmd> myprog 10 20 30

     /* myprog.c */
     #include 
     
      int main(int argc, char **argv) 
      {   
         int i;   
         for(i=0; i"%s\n", argv[i]);    
         return 0; 
     }
    

  12. A.

    10 20 30

    B.

    myprog 10 20

    C.

    myprog 10 20 30

    D.

    10 20

    View Answer

    Workspace

    Discuss Discuss in Forum