EEVblog Electronics Community Forum
A Free & Open Forum For Electronics Enthusiasts & Professionals
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
This topic
This board
Entire forum
Google
Bing
Home
Help
Search
About us
Links
Login
Register
EEVblog Electronics Community Forum
»
Electronics
»
Microcontrollers
»
C Programming Syntax
« previous
next »
Print
Search
Pages: [
1
]
Go Down
Author
Topic: C Programming Syntax (Read 1787 times)
0 Members and 1 Guest are viewing this topic.
Ground_Loop
Frequent Contributor
Posts: 644
Country:
C Programming Syntax
«
on:
December 01, 2021, 06:53:25 pm »
I ran across something similar to this and don't know how to interpret it. A = (B < C) D : E; Of course there were actual numbers and variables, but you get the idea. What is being assigned to A?
Logged
There's no point getting old if you don't have stories.
oPossum
Super Contributor
Posts: 1415
Country:
Very dangerous - may attack at any time
Re: C Programming Syntax
«
Reply #1 on:
December 01, 2021, 06:57:28 pm »
I think there is a question mark missing.
Code:
[Select]
A = (B < C) ? D : E;
That would be a ternary operator.
Equivalent to..
Code:
[Select]
if (B < C)
A = D;
else
A = E;
Logged
Ground_Loop
Frequent Contributor
Posts: 644
Country:
Re: C Programming Syntax
«
Reply #2 on:
December 01, 2021, 07:05:56 pm »
I was thinking the same, but there is definitely not a question mark. I'll consider it a typo.
Logged
There's no point getting old if you don't have stories.
DavidAlfa
Super Contributor
Posts: 5896
Country:
Re: C Programming Syntax
«
Reply #3 on:
December 02, 2021, 05:56:54 am »
For sure, the "?" is missing, if you try that syntax it will cause a compiling error.
Logged
Hantek DSO2x1x
Drive
FAQ
DON'T BUY HANTEK!
(Aka HALF-MADE)
Stm32 Soldering FW
Forum
Github
Donate
Print
Search
Pages: [
1
]
Go Up
« previous
next »
Share me
Smf
EEVblog Electronics Community Forum
»
Electronics
»
Microcontrollers
»
C Programming Syntax
There was an error while thanking
Thanking...
EEVblog Main Site
EEVblog on Youtube
EEVblog on Twitter
EEVblog on Facebook
EEVblog on Odysee