Q:

logic or syntax error?  C++

int rVals[];
string rNum;

for (i=0; i < rNum.length(); ++i) {
    if((rVals[i] < rVals[i+1]) && (rNum[i] =='C' || rNum[i]=='X' || rNum[i]=='I')){
        continue; //checks to see if preceeding value is < the next value
    } else {
        valid = false;
        cout << "you can't subtract by M, D, L, or V\n" << endl;
        break;
    }
}

rVals[] is a dynamic array and is set correctly.  No matter what the input is the if statement seems to evaluate to false.  what is wrong with the if statement? 

A:

Take a look at this: rVals[i] < rVals[i+1].  If rVals length is 10 for instance and i is 9 rVals[i+1] will "point" to the 11th element of the array (since the indexing of an array is starting from 0 and between 0 and 9 you heave 10 elements - the size of our array).