CS 284 Operating Systems
Programming Assignment #2
Due: 1/24/2001 - Class Time
Write a C program using all 3 arguments available to main(int argc,
char * argv[], char * env[] ).
Your progam should perform the following tasks:
-
Loop thru the argv array printing each command line argument that you supplied
- appropriately labeled
-
Test each command line argument's 1st character to determine if that character
is a number (use isdigit(..) )
-
If the character is a digit, print the argument as an integer (use atoi(..)
) appropriately labeled
-
Loop thru the env[] array printing
-
the 1st env[] string
-
the value associated with the HOST= env variable
-
the value associated with the USER= env variable
-
the last env[] string
-
Print a count of how many env variables there were
=================================================================
You will use the 'script' command to capture all necessary information
for handin. You do that by
starting the script command "script myHandin2"
cat your source.c program
run your program
exit
Remove the ^Ms from the script file.
a2ps myHandin2 | lpr -P yourPrinterPreference