I'm making a dieroller. I take the input in as a string, for example 1d1.
The first while loop finds the number before d, second the number after d.
I don't know why, but 'd' causes it to loop with 1d1, but with '2' and 121 as input it does not. What's wrong here?
That did not work, it is now stuck in the first while loop, regardless of input.
I've figured out that changing || to && fixes it, although i do not understand why. With input[i]!='d', should result in false when it is d. And I think false || true and false && true both result in the while loop being false.
This is the code so far, which functions with any input being <number>d/D<number>..
I don't know what would be a good way to stop the second loop with <number>d/D<number. (So without the dot).
cout << "Roll: ";
string input, x_str, y_str;
cin >> input;
int i=0, j=0;
while (input[i]!='d' && input[i]!='D')
// cout << "In the first loop. ";
// cout << "Out of the first loop. ";
// cout << "In the second loop. ";
cout << x<< y;