C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old October 11th, 2002, 10:38 AM
Houdini Houdini is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Location: Virginia Beach, Virginia
Posts: 7 Houdini User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question What is this?

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?

Reply With Quote
  #2  
Old October 11th, 2002, 10:58 AM
damonbrinkley damonbrinkley is offline
Modz
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: NC, USA
Posts: 364 damonbrinkley User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 m 18 sec
Reputation Power: 6
Send a message via AIM to damonbrinkley
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.

Reply With Quote
  #3  
Old October 11th, 2002, 11:12 AM
Houdini Houdini is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Location: Virginia Beach, Virginia
Posts: 7 Houdini User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Ahhhh.

So its short hand for an if..else basically.

Reply With Quote
  #4  
Old October 11th, 2002, 01:15 PM
Analyser's Avatar
Analyser Analyser is offline
*bounce*
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2002
Location: Delft, The Netherlands
Posts: 510 Analyser User rank is Corporal (100 - 500 Reputation Level)Analyser User rank is Corporal (100 - 500 Reputation Level)Analyser User rank is Corporal (100 - 500 Reputation Level)Analyser User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 20 h 27 m 53 sec
Reputation Power: 9
Send a message via ICQ to Analyser
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/

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > What is this?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway