I am having a little trouble working with nested conditional operators in C.
int is_correct() {
char YN ;
printf( "Y or N : " ) ;
scanf( "%c", &YN ) ;
YN = toupper( YN ) ;
return ( YN == 'Y' )? 1 : ( YN == 'N' )? 0 : is_correct() ;
}
I was under the impression that the last line of code would return 1 or 0 if a 'Y' or 'N' was entered or call itself again if an unexpected character was entered. Instead it continuously calls itself no matter the input.