I'm building a set of functions in an included file, and i would like to be able to run my test main() to call the function name passed on the command line. Something like this:
void rotate (int degrees) {
/*...*/
}
void translate (int pixels) {
/*...*/
}
int main(int argc, char* argv[] ) {
const int degs = 100;
const int pix = 250;
string func = argv[1];
//call func(degs) or func(pix) based on the command line argument passed
}
I'd like to be able to run this like % a.out translatefrom the command line. What is the syntax to make this work. Thanks in advance I looked for a while on this one and couldn't find anything.
if string(argv[1])=="rotate") { ...I can make this work. I was wondering if there is a more direct way.