Discussion
Which of the following gives the name of the program if the second parameter to the main fucntion is char **argv?
Answer: C
Correct answer: argv[0]
argv[0] holds the name by which the program was invoked, whether argv is declared as an array of pointers or as char ** - the two are equivalent as parameters.
The arguments proper begin at argv[1], which is why a program testing for arguments writes if (argc > 1). The exact contents of argv[0] are a platform convention: Unix-like systems supply the string as typed, while some others give a full path.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development