Okay I know this is a super newbie question so I will give you some background.
I am breaking down a tic tac toe source code to see how it works. For me that is one of the ways I learn. This piece of code is in my main and I have figured out most of it but for some reason I just can't figure that out. The main is below.
Now the thing is I was studying multi dimension arrays (very interested in that). So this code is way ahead of what I am studying so far. So, I may be way off because On line 2 I am thinking that it is a variable with 3 values??? Am I really wrong here.
Outside a parameter list context, a comma-separated list of expressions will cause the compiler to fully evaluate all expressions within the list. In any context except for the aforementioned context, the right-most expression -- "choice" in your case -- will always be used; the other (s) will be ignored. In an assignment context, the rules still apply. For instance:
1 2 3 4 5
// Comma-separated list inside an assignment context:
int a(1, 2, 3); // a has the value of 3.
// Comma-separated list outside an assignment context:
1, 2, 3; // 3 will be the expression used by the compiler.
Comma-separated lists can be used to evaluate two or more similar expressions within one statement. The "for" loop supports this also. Note that the order of evaluation is undefined during a function invocation.
Now the thing is I was studying multi dimension arrays (very interested in that). So this code is way ahead of what I am studying so far.
IMO a 2 dimensional array is the easiest way of doing this, because it is easy to do lots of things with nested for loops.
For that reason, IMO, the code you have is not a very good example to learn from. Quite a lot of people have done tic-tac-toe programs on this site - so I would search for one that uses a 2d array. Look for one that uses functions well, does not have too much repetition, and hopefully has meaningful variable names and is reasonably easy to understand.
The ternary ?: operator is a short cut for if-then-else:
conditional ? true statement : false statement
if the condition evaluates to true then the true statement is executed, otherwise the false statement is executed.
It is the same as:
1 2 3 4
In the case of your example it is used with assignment as well - so the variable mark is assigned either X or O depending on the conditional.
Because I know I am jumping way ahead of the level of study I am on. The multi dimensional arrays peaked my interest a lot. This tic tac toe code sidetracked me but I learned a lot from trying to break it down. Coder777 and TheIdeasMan I will take your advise and try to find a better example.
Then back to my regular studies. See you around the forum.