hi sorry to ask such a basic question but what does the ? character do in c?
hi sorry to ask such a basic question but what does the ? character do in c?
It is one part of the trinary operator.
Just like in the english language ? denotes a question.
syntax is: condition ? true : false
So basically its: is condition true? If true do the true statement, if not do the false statement
It is a handy operator that is not limited to output. An example in code
It's late for me, but the output *should* read: you have 1 item remaining.Code:int items = 1; printf("you have %d %s remaining.", items, items > 1 ? "items" : "item");
I haven't used a compiler in ages, so please be gentle as I try to reacclimate myself. :P
They are also a part of trigraphs, some special sequences of three characters (most probably you won't ever need to use trigraphs)
http://www.opus1.com/vmsdoc/progtool...igraph_seq_tab
The one who says it cannot be done should never interrupt the one who is doing it.