Hi All,

I am trying to run my code based on the command line argument.
Following is the partial code:
Code:
int main(int argc, char *argv[]){
  std::cout<<"******************************"<<std::endl;
  std::cout<<std::endl;
  std::cout<<"Method is: "<<argv[1]<<std::endl; // prints command line argument
  .........
..............
...................
}
I want to check if the user has mentioned any command line argument or not, one simple way is to check "argc".....but I just want to know how do we check it through "argv[1]". For example, if i write the following code:
Code:
if(argv[1]==''){ //empty character
    std::cerr<<"Method Missing"<<std::endl;
    exit(1);
  }
It doesn't work, as compiler says empty character constant.
If I use the following:
Code:
if(argv[1]==""){ //string literal
    std::cerr<<"Method Missing"<<std::endl;
    exit(1);
  }
Then the compiler warns me of: comparison with string literal results in unspecified behavior

Can you guys suggest me, what is the best way.

Thanks.