I am trying to return true if the two arrays have common values and return False otherwise. the problem is when running this code I found that arrays are not as declared. one of the two arrays contains the values of both arrays
Here is the Code:
#include<bits/stdc++.h>
using namespace std;
bool commonValues(char arr1[], char arr2[]){
for (int i = 0; i < strlen(arr1); i++){
for(int j = 0; j < strlen(arr2); j++){
if (arr1[i] == arr2[j]){
return true;
}
}
}
return false;
}
int main(){
char arr1[] = {'a', 'b', 'c', 'd', 'z', 'x', 'k', 'l'};
char arr2[] = {'e', 'f', 'g', 'h'};
for (int i = 0; i < strlen(arr2); i++){
}
cout<<commonValues(arr1, arr2)<<endl;
return 0;
}