In DOS/Turbo C style execution, argv[0] typically contains the full path of the running program. If the file myproc.c is in "C:\TC" and you run MYPROC.EXE from that directory, what does this program print?
/* myproc.c */
#include
int main(int argc, char *argv[])
{
printf("%s", argv[0]);
return 0;
}
-
ASAMPLE.C
-
BC:\TC\MYPROC.EXE
-
CC:\TC
-
DError
-
Emyproc
Answer
Correct Answer: C:\TC\MYPROC.EXE
Explanation
Introduction / Context: The problem reinforces that argv[0] is conventionally the program name or path with which the program was invoked. Under DOS/Turbo C, it often includes the full path and .EXE name when launched from the shell.
Given Data / Assumptions:
- Executable is MYPROC.EXE located in C:\\TC.
- Launched from that directory, so the shell provides the full path.
- Program prints argv[0] verbatim.
Concept / Approach: argv[0] is populated by the host environment. Although not strictly standardized to be a full path, in this DOS/Turbo C context it typically is something like C:\\TC\\MYPROC.EXE when executed directly from that location.
Step-by-Step Solution:
At launch, argv[0] receives the path of the executable. printf("%s", argv[0]) prints that exact string. Hence, output is C:\\TC\\MYPROC.EXE.Verification / Alternative check: If you placed the EXE elsewhere or invoked via PATH without full path, argv[0] might differ, but the question specifies the DOS/Turbo C scenario yielding the full path.
Why Other Options Are Wrong:
- SAMPLE.C: That is a source file name, unrelated here.
- C:\\TC: That is a directory path, not the executable path.
- Error: There is no runtime error; printing a valid string is fine.
- myproc: Possible on some systems, but the question frames the full-path behavior.
Common Pitfalls: Assuming argv[0] is always just the program name; environment conventions vary across systems and shells.
Final Answer: C:\\TC\\MYPROC.EXE