Comparing the values of char arrays in C++

后端 未结 5 1822
广开言路
广开言路 2021-01-02 02:38

I have problem about doing something in my program. I have a char[28] array keeping names of people. I have another char[28] array that also keeps names. I ask user to enter

5条回答
  •  借酒劲吻你
    2021-01-02 02:57

    You can write code for your own char array compare function. Let's start

    //Return 0 if not same other wise 1
    int compare(char a[],char b[]){
        for(int i=0;a[i]!='\0';i++){
            if(a[i]!=b[i])
                return 0;
        }
        return 1;
    }
    

提交回复
热议问题