Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Purpose of a function (http://www.go4expert.com/forums/purpose-function-t23432/)

arun10427 28Sep2010 09:44

Purpose of a function
Hello all,

func(int* a, int b)
while((*a&(1 << b))==0);

Can someone tell me the hidden purpose of this code?

shabbir 29Sep2010 08:34

Re: Purpose of a function
Depending on the values of a and b it will execute.

xpi0t0s 2Oct2010 12:52

Re: Purpose of a function
It will either do nothing (if *a & (1<<b) is zero) or hit an infinite loop (if *a & (1<<b) is non-zero).

Best bet is to go after whoever wrote that code and give them a good LARTing, or at least ask them what the point of the function was, because they've almost certainly coded it wrong.

*IF* the function is within a multithreaded program and some other thread is modifying *a, then it might be useful - it would wait until the b-th bit of *a is clear. But this is a terrible way of doing it because it uses 100% CPU until that is done.

All times are GMT +5.5. The time now is 01:58.