Question: Operating Systems: 2. Write a C program printing to sdout all its arguments (including argv[0]), one per line, followed by all its environment variables (again,
2. Write a C program printing to sdout all its arguments (including argv[0]), one per line, followed by all its environment variables (again, one per line) You can access environment variables using the following variant for your main function int main(int argc, char *argv[], char* env[]) The environment variables are stored as an array of strings in the variable env. This array is terminated by an element whose value is NULL. Save the source code of this program in printargsandenv.c If you run the code of this C program in the folowing way: ./printargsandenv argument1 argument2 the output shuld be similar to: ./printargsandenv argumenti argument2 XDG VTNR- ORBIT SOCKETDIR-/tmp/orbit-antoniob XDG SESSION ID c1 VIRTUALENVWRAPPER SCRIPT-/usr/share/virtualenvwrapper/virtualenvwrapper.sh XAUTHORITY-/home/antoniob/.Xauthority COLORTERM-gnome-terminal -/printargsandenv OLDPWD-/home/antoniob/git (I omitted many lines. Also, the values of your environment variables will likely be different.)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
