Posted by: DS2K3 Mar 12 2005, 09:43 AM

do{}while is like suing while(), except that the statement in the while() brackets is only evaluated AFTER the first loop. I'm not a C programmer, but I tihnk 0 would make the evaluation false, and therefore the loop would only go round once.

D

Posted by: Hemant Mar 12 2005, 10:37 AM

Ok..i think i got it.

The code snippet you have given is clearly used to initialise a doubly linked list.Now the whole thing is defined as a macro.

But as you know macros are quite tricky and nasty stuff...and that is the reason why.

CODE

#define MUL(a,B) a*b

and

#define MUL(a,B) (a)*(B)

can give quite different results,depending upon the arguments passed to it.If you have got your lesson in C,you can easily figure out how?

So sometimes it becomes quite necessary to have parenthesis around your statements.Now in our case the whole macro is a bit complex and thus just as a workaround and to make sure that statements stay together for any kind of argument,they have used do{}while().

Otherwise for normal arguments,the do{}while() is redundant.It is just like making the code bulletproof.If you remove the do{}while() then you will have two statements for a single macro and it is quite obvious that only one will be used.of course they could have done something like this..