Checking argv[] against a string? (C++)

前端 未结 5 727
情歌与酒
情歌与酒 2020-12-28 15:05

So I\'m attempting to check the arguments that I\'m inputting into my program, and one of them is either the word \"yes\" or \"no\", entered without the quotes.

I\'

5条回答
  •  庸人自扰
    2020-12-28 15:18

    if(strcmp(argv[0],"yes")==0) { // equal to "yes"
    

    strcmp is zero if the 2 strings are the same.

提交回复
热议问题