Okay, for a homework assignment my professor wants us to write a program in C++ that converts from miles to km. I did all that, the program runs. However, he has this special way of calling the program:
The program's usage options are based on the NAME of the BINARY FILE. If the program name is 'km2miles', the program interprets the command line argument as a kilometer value to convert to miles. If the name is 'miles2km', then it interprets as miles being converted to km. Since the first command line argument, argv[0] is always the program's name, you can use its value to decide which function to call.
I only have 3 files in this project (he tells us to ONLY have these 3): convert.cpp distance.cpp distance.h
Distance .h and .cpp have the different functions to convert Mi to Km and Vice Versa, the convert.cpp has the main function. However, the only way I know how to call this program (after compiling it) is to say:
./convert 10
Where 10 is the number to convert. He says it should be called like this:
$ km2miles 100
and
$ miles2km 60
I have no idea how to get the program to act differently by having a different name... especially when that name doesn't even run the program! Help would be appreciated.