Liste des Groupes | Revenir à cl c |
On 02/11/2024 11:41, David Brown wrote:
>On 01/11/2024 20:47, Bart wrote:
>On 01/11/2024 18:47, David Brown wrote:>
>On 01/11/2024 19:05, Bart wrote:>
>On 01/11/2024 17:35, David Brown wrote:>>>>
What you have written here is all correct, but a more common
method would be to avoid having three printf's :
>
void shout_a_number(int n) {
printf( (const char* []) { "ONE", "TWO", "THREE" } [n] );
}
>
That's more likely to match what people would want.
I was also trying to show that all elements are evaluated, so
each has to have some side-effect to illustrate that.
Fair enough.
>A true N-way-select construct (C only really has ?:) would>
evaluate only one, and would deal with an out-of-range condition.
That's a matter of opinion and design choice, rather than being
requirements for a "true" select construct.
I don't think it's just opinion.
Yes, it is.
Then we disagree on what 'multi-way' select might mean. I think it
means branching, even if notionally, on one-of-N possible code paths.
>
The whole construct may or may not return a value. If it does, then
one of the N paths must be a default path.
Les messages affichés proviennent d'usenet.