Hi, I am trying to pass input arguments in my C++ code, so I have declared my main method as main(int argc, Char *args[]) and when I have my input argument then I wanted to parse it to another method [Method1(const char *Arg) the problem is that i am not able to convert the Char *args[2] to const char Arg[].
Here is my code snippet
int main(int argc, char *args[])
{
if (argc>1)
{
if (!RunMethod1(args[2]))
{
return 0;
}
return 1;
}
Bool RunMethod1(char *loc)
{
static const char Args[]= //Here I need to convert the *loc to const char []
Method1(char *Args)
}
static bool Method1(const char *Args)
{
}
Please let me know how to do this. Thanks in advance.
if (argc>1).. if that evaluates true, it does not mean that args[2] is present.
Bool is not capitalized.
Static data in functions will only be initialized one time (the first time the function is called.) If you use RunMethod1 again in the program, your argument to the function will be ignored.