I have this code:
cin >> command;
if (command[0] == 'R' or command[0] == 'r') {
    if (command[1] == 'o' and command[3] == 'l' and command[2] == 'l') {
        if (command[4] == '\0') {
            cout << rand()+ 1 << endl;
        } 
        else if (command[5] == '\0')
        {
            NumberName = command[4];
            cout << (rand()%NumberName)+ 1 << endl;
        }
        else if (command[6] == '\0')
        {
            NumberName = command[4] + command[5];
            cout << (rand()%(NumberName))+ 1 << endl;
        }
    }
}
Running it produces random numbers outside of the range.
command is an array with a limit of 30.
NumberName is just a normal int.
I enter roll10 in the console and it returns 90 then 34 then 51, you get the idea.