lundi 18 mai 2020

How can I use a conditional operator in printf but without the "else" part?

printf ("%d ", digitscont(&myarray[i-1]) ? myarray[i-1] : );     // I'd like to do print nothing in the else part.

If I leave : without anything, it gives me an error:

error: expected expression
                printf ("%d ", digitscont(&myarray[i-1]) ? myarray[i-1] : );
                                                                         ^
1 error generated.

How can I make my program to print nothing if the function digitscount returns 0?

Aucun commentaire:

Enregistrer un commentaire