|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Where can I find documentation for the folllowing code. I know all about argv and argc. What is the "(x) ? x : x" part?
(i < argc-1) ? " " : "" I've also seen integers used in place the chars as well. Anyone? |
|
#2
|
|||
|
|||
|
It's a conditional expression.
expr1 ? expr2 : expr3 expression expr1 is evaluated first. If it's true then expr2 is evaluated and if it's not then expr3 is evaluated. |
|
#3
|
|||
|
|||
|
Ahhhh.
So its short hand for an if..else basically.
|
|
#4
|
||||
|
||||
|
Well, sort of. But an if-else construct is a statement, whereas the ternary ?: operator results in an expression. Example:
a = (x < y) ? x : y; So yes, it's like an if-else statement in the sense that there's a conditional expression involved, but that's about it.
__________________
"A poor programmer is he who blames his tools." http://analyser.oli.tudelft.nl/ |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > What is this? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|