My code has an error and I have no clue why. It works just fine and runs perfectly, but the error will not go away.
The compiler is scared because it's not sure if the `scan` function will return something or not. This is because the function contains just IF-ELSE statement and it's not sure wether any of them will be evaluated as "true" If all of the condition evaluates to false,then the control will reach the end of function, without returning something,which is WRONG. You must explicitly return "" after the conditional statement or better restructure your code to return everything at the end of the control using ternary operators
You have one more It has to be r = rand() % 3 + 1 and add srand(time(0)) as well
In the scan function if num is not equal to 1 2 or 3 you dont return a value