I'm trying to compare my array elements, but when I compile it, the class member array does not show the values I copied into the array from my original array in main "key",
 but the array from main, "answer" keeps the values I enter, and I wrote a test loop after the program runs, just to see what's inside of the class member array"canswers", and it's the actual variables that I copied into the array from main "key". I'm trying to compare the two arrays ("canswers" and "answer") in the class function "grade", but I do not know what I'm doing wrong.Every time I compare them through a for loop, with an if statement, it does not work, and random characters appear. I wrote a test loop at the very end of the array to show the contents of the class member array "canswers", an it has all the right values that I copied from main, but it doesn't show or work when I compare the two. I tried to keep the code as clean as possible so you guys can easily read it.

```
#include<iostream>
#include<string>

using namespace std;

class TestGrade
{   
    public: 
        void setKey(char []);
        void grade(char []);
        char canswers[];
        void display();
}; 

void TestGrade::setKey(char answers[]) //setting values from "key" array in main
{
    for(int index = 0; index < 19; index++)
    {
        canswers[index] = answers[index]; 
    }
}

void TestGrade::grade(char answer[])  //comparing elements in array, here's where the 
{                                     //trouble begins
    for(int index = 0; index < 19; index++)
    {
        cout << canswers[index] << " " << answer[index] << endl; 
        if(canswers[index] == answer[index])
            { cout << "The values are equal" << endl;}
    }
}

void TestGrade::display()       //testing the values after the loop i had trouble with
{
    for(int index = 0; index < 19;index++)
    {
        cout << canswers[index] << endl;
    }
}

int main()
{
    const char SIZE = 20;
    char answer[SIZE];
    char key[20] = {'B', 'D', 'A', 'A',
                    'C', 'A', 'B', 'A',
                    'C', 'D', 'B', 'C',
                    'D', 'A', 'D', 'C',
                    'C', 'B', 'D', 'A'};

    TestGrade test1,test2;

    test1.setKey(key);

    cout << "Welcome to the written portion of the DMV exam. \n";
    cout << "You may only enter capital A, B, C, or D for your answers.\n\n" << endl;

    for (int index = 0; index < SIZE; index++)
    {
        cout << "Enter your answer for question " << index+1 << endl;
        cin >> answer[index];

        while (answer[index] != 'A'
            && answer[index] != 'B'
            && answer[index] != 'C'
            && answer[index] != 'D')
        {
            cout << "ERROR: you must input capital A,B,C, or D" << endl;
            cin >> answer[index];
        }
    }

    test2.grade(answer); // comparing the values of canswer[] and answer[]

    test1.display();  //test loop testing contents of canswers[] class member array

    system("pause");
    return 0;
}

```