简体   繁体   中英

conditional check for command line arguments in c++

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?

'a' is an int (more accurately 1 byte integer)

"a" is a string

Replace 'a' with "a"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM