This means keep doing the loop as long as the thing in the brackets comes out as TRUE. Let's look at the thing in the brackets.
function != 'q' || 'Q'
It's an OR statement. An OR statement comes out as TRUE if either side, or both sides, are TRUE.
Let's look at the left hand side. function != 'q'
So, this will be TRUE is function isn't 'q', and FALSE for all other cases.
Let's look at the right hand side. 'Q'
Is'Q' TRUE or FALSE? Well, in C and C++, zero is false and non-zero is true. This is not zero, so it's TRUE. Always and forever. So this: function != 'q' || 'Q'
has the right hand side as always true, so this while (function != 'q' || 'Q' );
will always come out as TRUE. Always always always.
Now you repeat the analysis for while (function != 'q' && function != 'Q' );