Difficulty: Medium
Correct Answer: List of all environment variables
Explanation:
Introduction / Context:
This question clarifies that many DOS/Turbo C compilers support a third parameter to main for environment variables (envp). With a correct signature, you can iterate over env and print strings like PATH, COMSPEC, etc. The original snippet had an incorrect argv type; here it is repaired to avoid type issues.
Given Data / Assumptions:
Concept / Approach:
The environment vector is analogous to argv: it is an array of C strings terminated by a NULL pointer. Printing them yields lines like "PATH=...". The repaired function signature ensures %s receives a proper char*.
Step-by-Step Solution:
Verification / Alternative check:
If you replace env[i] with argv[i], you would print command-line arguments instead. Using env confirms distinct vectors.
Why Other Options Are Wrong:
Common Pitfalls:
Mixing up argv and envp or assuming envp is unavailable on older compilers; in practice, many did support it.
Final Answer:
List of all environment variables
Discussion & Comments