How to compare char variables (c-strings)?

后端 未结 5 1476
小鲜肉
小鲜肉 2020-12-22 10:44
#include 
using namespace std;

int main() {
    char word[10]=\"php\";
    char word1[10]=\"php\";

    if(word==word1){
        cout<<\"word          


        
5条回答
  •  醉酒成梦
    2020-12-22 11:00

    To justify c++ tag you'd probably want to declare word and word1 as std::string. To compare them as is you need

    if(!strcmp(word,word1)) {
    

提交回复
热议问题