:: Re: [DNG] Studying C as told. (For …
Góra strony
Delete this message
Reply to this message
Autor: Edward Bartolo
Data:  
Dla: dng
Temat: Re: [DNG] Studying C as told. (For help)
Hi,

<<
A
switch statement cannot jump a successive number of lines but my
little example can.
>>


Rereading my previous email, I think this is a mistake on my part. A
switch's default clause can be used to execute such a number of lines.
The only thing that a switch cannot do is use a non-constant object as
its case control value.

I am sending this to avoid readers responding to explain something a
short reading about the switch statement can easily teach within a few
minutes.

Edward

On 25/06/2016, Edward Bartolo <edbarx@???> wrote:
> Hi,
>
> With a switch statement execution continues immediately after the
> switch. My example also involved a chunk of code that followed the
> series of if statements that was also skipped by the goto jump. A
> switch statement cannot jump a successive number of lines but my
> little example can. In fact, I used it back in 1995 when I programmed
> an expression evaluator.
>
> Edward
>
> On 25/06/2016, Edward Bartolo <edbarx@???> wrote:
>> om: Edward Bartolo <edbarx@???>
>> Hi,
>>
>> On 25/06/2016, KatolaZ <katolaz@???> wrote:
>>> On Sat, Jun 25, 2016 at 09:27:40AM +0200, Edward Bartolo wrote:
>>>
>>> [cut]
>>>
>>>>
>>>> execution continues from here
>>>>
>>>> This can still be done by something like this:
>>>> do {
>>>> if (test1) break;
>>>> if (test2) break;
>>>> if (test3) break;
>>>> ...
>>>> if (testN) break;
>>>>
>>>> more code here
>>>> } while (0);
>>>>
>>>> execution continues from here
>>>>
>>>
>>> This can be even achieved using the switch/case statement....
>>>
>>> HND
>>>
>>> KatolaZ
>>
>> Switch/case mandates "case constant-expression:" which is far more
>> restrictive compared to a series of if statements. 'If' can take ANY
>> expression as its control expression. This makes a whole difference in
>> its applicability field. I am NOT saying a switch statement is to be
>> avoided. In fact, in the source code of simple-netaid-backend, I used
>> it.
>>
>> Edward
>>
>