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,

Operating Systems:
 Operating Systems: 2. Write a C program printing to sdout all

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!