it works through the cout << test print for smallDigitLoop 2. but can't get the rest of the code to work they way I want to. trying to compare all the values in the array and store the largest digit to compareIntGreater.
return will escape from main.
I've tried to comment these lines and the execution goes trougth the second loop.
Maybie you meant break and not return ?
I've not tested the code so far, can't tell if it works properly.
Maybe you wanted to write (digitTwo[countTwo] > digitTwo[--countTwo]) ;
However, this is also dangerous because we don't know exactly how the compiler will deal with this statement, the right side will be calculated first, or the left side?
Never do this. There's no way of knowing whether or not the -- operator will be evaluated before the first countTwo expression is evaluated. You get undefined behavior.
That is... if you have the below code:
1 2
int a = 1;
if( foo[a] > foo[a--] ) // <-
that line might compare foo[0] to foo[1]. Or it might compare foo[1] to foo[1]. There's no way to know which you'll get.
EDIT: chenqi beat me to it, although note the behavior is undefined so it won't necessarily always be true. The actual result you get is completely unreliable.