Discussion
If the following program (myproc.c) is present in the directory "C:\TC" then what will be output of the program if run it from DOS shell?
/* myproc.c */
#include <stdio.h>
int main(int argc, char *argv[])
{
printf("%s", argv[0]);
return 0;
}
Answer: B
Correct answer: C:\TC\MYPROC.EXE
Under MS-DOS from version 3.0 onwards, the full pathname of the executable is available to the program, and Turbo C places it in argv[0] in upper case with the .EXE extension.
That is a platform convention rather than a rule of the language. The C standard says only that argv[0] represents the program name, and leaves the form open - on Unix-like systems it is generally the string the user typed, so the same program invoked as ./myproc would report exactly that.
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