I am trying to use a switch statement to start function calls. The value that needs to be passed into the switch statement in an argument that comes from the command line arguments, meaning that it is stored in argv[]. In my case, this argument is known to be stored in argv[5]. My problem is that I do not know how to properly convert or store the value found in argv[5] so that it can be read by the switch statement. I have tried using char*, char[], and string as the data type of my variable 'verbosity'
The error that I keep getting is this: statement requires expression of integer type ('char *' invalid) switch(verbosity) ^ ~~~~~~~~~
And my code is as follows:
char* verbosity = argv[5];
cout << endl << verbosity;
switch(verbosity)
{
case 'vlow':
{
vlow();//calls vlow function
break;
}
case 'vmed':
{
vmed();//calls vmed function
break;
}
case 'vhigh':
{
vhigh();//calls vhigh function
break;
}
default:
break;
}
Is there a certain format that I should be using to pass a string from argv[] into my switch statement?