Bug with replacing elements in 2D Vector

Hi! I have a 2D Vector defined as vector
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
    void initGridFromInput(vector <vector <int> > & sudokuGrid){
    cout << endl << "Enter one row at a time without spaces between characters." << endl;            string line;
    for (int i = 0; i < ROWS; i++){
        while (true){
            cout << "Enter row: ";
            cin >> line;
            if (line.length() == COLS) break;
            else {
                cout << "The row must have 9 characters." << endl;
            }
        }
        vector <int> rowVector(COLS);
        for (int j = 0; j < COLS; j++){
            cout << "Line[j] = " << line[j] << endl; // Find j'th character of line
            cout << "Before: " << rowVector.at(j) << endl; // jth element of vector before
            rowVector.at(j) = line[j];
            cout << "After: " << rowVector.at(j)<< endl; // jth element of vector after
        }
        sudokuGrid.at(i) = rowVector;
        cout << endl;
    }
    
}

For some reason, the cout statements print out:

Enter row: 763418259
Line[j] = 7
Before: 0
After: 55
Line[j] = 6
Before: 0
After: 54

and this continues...

What is wrong with my code? I am used to using the C++ libraries given by Stanford so using the STD version of vector is taking some getting used to.
character '1' does not equal to integer 1
try this to understand:
1
2
int x = '7';
std::cout << x;
line[j] is a char. The '7' is a character that looks like, well, seven. However, that printable character has integer value too (just like 'a' does too). That seems to be 55. (See ASCII, and other character encodings.)
Topic archived. No new replies allowed.