checking 2 arrays

closed account (Dz0RfSEw)
I have to check 2 arrays to see if the characters are the same in both spots and the characters have to be the same, so an uppercase C is the same as another uppercase C in the same spot or c is the same as c but C is not the same as c. not sure how to check the letters though. So far I have this:
int CheckArrays(char ArrayA[], char ArrayB[], int& length1, int& length2)
{
int count;
int index = 200;
int counter = 0;

for(count=0; count<index; count++)
{
if(ArrayA[count] == ArrayB[count])
{
counter++;
}
}
return counter;
}
Last edited on
Line 7: index is unititialized. You're going to go through the loop an indeterminate number of times.

You need to consider how to handle the situation where length1 and length2 are different.

PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Topic archived. No new replies allowed.