Reputation: 15
How can me check for a condition using command line arguments in C++, for example I got a code like this
int main(int argc, char* argv[]) {
if (strcmp(argv[1] , 'a')==0)
{
cout<<"something"<<endl;
}
}
with the arguments hello, hi etc., when my argv[1] == "hello", I want to execute some statements. This comparison is throwing an error char is incompatible with const char* Is there a better way to compare these arguments?
Upvotes: 0
Views: 814
Reputation: 12227
'a' is an int (more accurately 1 byte integer)
"a" is a string
Replace 'a' with "a"
Upvotes: 3