I have two char string and they have '-' and '+' sign.
I want to pick a random sign from a variable. So far i tried like this, but it outputs only '+' - sign, how can i make it correct?
srand(time(0)); char rand_symb; char plus = '+'; char minus = '-'; rand_symb = rand() % (plus - minus + 1) + minus;
rand_symb = "+-"[rand() % 2];%(plus-minus)+minusonly works if plus and minus are adjacent in the ascii table and minus comes before plus. Both assumptions are wrong.rand_symb = rand() % (plus - minus + 1) + minus;sorry, but this looks like cargo cult programming to me