I have one textline that says "This is cool" stored in a 2d array called arr. arr[0] would be "This", arr[1] would be "is" and so on. I have another 2d array with user inputted words. I need to compare every word in the userinput array to every word in the arr array to see how often each word in the userinput array occurs in the arr array.
Here is the code for that:
for (int i = 0; i < boo; i++) {
occurrence = 0;
for (int j = 0; j < baa; j++) {
if (*arr[j] == *userinput[i]) {
occurrence += 1;
}
if (j == baa-1) {
cout << userinput[i] << " occurs " << occurrence << " times \n";
}
}
}
Note that boo is the amount of items in the userinput array, and baa is the amount of items in the arr array
The issue is this program is only comparing the first letter of each word, so the word island will count the same as the word icecream. Any suggestions on how I can compare the entire word rather than just the first letter?