How to compare char variables (c-strings)?

后端 未结 5 1426
小鲜肉
小鲜肉 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

    Use std::string objects instead:

    #include 
    #include 
    using namespace std;
    
    int main() {
        string word="php";
        string word1="php";
    
        if(word==word1){
            cout<<"word = word1"<

提交回复
热议问题