Milestone 1:
Write a C main program called assign11.c which will output to standard error a line indicating the number of command line arguments that the program was given. As usual, count the program name as the first command line argument. The prototype for your main program should be:
void main(int argc, char *argv[]);If your program is called with:
assign11 abc def 7the program should output:
This program was written by ... assign11 was called with 4 tokens on the command line.The name assign11 should be gotten from argv[0].
Milestone 2:
Copy assign11.c to assign12.c and modify it as follows. The program will take 0, 1, 2, or 3 string command line arguments after the name of the program. If this is not the case the program should exit with an appropriate error message. Put the following at the top of your file:
#define DEFAULT_MEMORY "memory" #define DEFAULT_CONTROL_STORE "control_store" #define DEFAULT_MAC_DEF "mac_def"These will be the default values for three strings in the program. Your main program will have three local string variables (type char *) called memory_filename, control_store_filename, and mac_def_filename. These will be set based on the default values and the command line arguments. Your program will print out the strings pointed to by these pointers. For example, if your program is called with:
assign12it will print:
This program was written by ... memory_filename: memory control_store_filename: control_store mac_def_filename: mac_defIf it is called with:
assign12 new_mem new_controlif will print:
This program was written by ... memory_filename: new_mem control_store_filename: new_control mac_def_filename: mac_defNote that the file names should be lined up in a column.