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.
Please log in or register to report this question.