If statement with ? and : [duplicate]
This question already has an answer here: What does the question mark and the colon (?: ternary operator) mean in objective-c? 13 answers I heard about a kind of If statement which use ? and : in C I dont know how to use it and I cant find anything about it. I need to use it in order to shorten my code any help would be appreciated. ?: is ternary operator in C (also called conditional operator). You can shorten your code like if(condition) expr1; else expr2; to condition ? expr1 : expr2; See how it works: C11: 6.5.15 Conditional operator: The first operand is evaluated; there is a sequence