Matrix Function

I have a test where I have to create a program which assists the user with matrix functions.

The main problem I have is in the instructions, which goes as follows:
The Mathematics Department at Whatsamatter University has contracted you and your partner to develop a program to assist their students with learning how matrices function. This program will, from the command line, accept a varying amount of parameters.

If there is one parameter, besides the name of the program (matrix) on the command line, then the program will either create a new matrix file or open the file for editing/display. Matrix files all end with .mat, but the user does not have to enter the .mat as part of the parameter (ex. matrix one would open the one.mat for editing/display if it exists, or create a new matrix file if it does not exist)

If there are two parameters, besides the name of the program on the command line, then the program will error out and display a helpful message on how to use the program.

If there are three parameters, besides the name of the program on the command line, then the program will perform the operation desired upon the two existing matrix files and display the result on the screen in proper matrix format. (ex, matrix one multiply two will multiply matrix one by matrix two)

If there are four parameters, besides the name of the program on the command line, then the program will perform the operation desired upon the two existing matrix files and display the result on the screen in proper matrix format as well as create a new matrix file with the resultant matrix within it. (ex. matrix one add two three will display the result on the screen as well as make a new matrix file called three.mat). If the file name exists, the program must prompt the user to see if they wish to overwrite it or create a new, different named, file.

If there are five parameters, besides the name of the program on the command line, then the program will perform the operation desired upon the two existing matrix files and display the result on the screen in proper matrix format as well as create a new matrix file with the resultant matrix within it; regardless of whether or not the file already exists. (ex. matrix one add two three /f will display the result on the screen as well as make a new matrix file called three.mat).

My question is, what does he mean by 2 parameters, 3 parameters etc?

When I create the function of a command line, don't I have to manually dictate how many parameters it takes? Thus, how do I create a function where it dynamically creates parameters as it goes?

I am very confused, any help is much appreciated!

I think it's talking about command-line arguments to the program:
1
2
3
4
5
6
7
8
9
#include <iostream>

int main(int argc, char* argv[])
{
    std::cout << "The name of this program is: " << argv[0];
    std::cout << "\nAdditional arguments (if any) passed to this program:\n";
    for (int i = 1; i < argc; ++i)
        std::cout << argv[i] << '\n';
}
Try running this program on the command line with various arguments.
For instance:
http://coliru.stacked-crooked.com/a/877ff911edd8a7a5
Last edited on
Did you input the hello, how, are, you, today?

How can this be done with my example?


Also, how do I create a file? this was not taught in class at all
that is a really odd question.. where do the values in the matrices come from? would be my first step.. i had to create a program a few weeks ago that populated and calculated matrices.. is that what you have to do as well?
Yes I have to do that as well, but depending upon how many parameters the user desires in the command line.
Topic archived. No new replies allowed.