Description
The objective of this assignment is to help students understand the significance of the argv array in C programming and practice working with two-dimensional arrays to mimic command-line arguments when argv is not available. Therefore, you will create a C program that simulates the behavior of command-line arguments without using the argv array. Instead, you will use a two-dimensional character array to accept and process command-line inputs.
Requirements:
1. Use a two-dimensional character array to store and process command-line arguments. You should define the array as follows: char args[argc][length], where argc is the maximum number of arguments your program can accept, and length is the maximum length of an individual argument.
2. Implement a function called parseCommandLine that takes user input as a string and populates the args array. The user input should be entered as a single string with space-separated arguments.
3. The program should print the number of arguments and the list of arguments.
4. Use proper error handling. If the number of arguments provided exceeds the capacity of the args array, print an error message and terminate the program.
Sample Run:
$ ./HW4
Enter command-line arguments: ls -l -a
Number of arguments: 3
Argument 0: ls
Argument 1: -l
Argument 2: -a