fun("000001010") will return decimal value of 000001010 i.e. 10
r is initialised to 0
for(; *s; r=(r<<1)|(*s++ - '0'));
*s is condition checking here and will fail when we will reach end of string 000001010
*s++ will point pointer s to next bit of the string
initially r=0 //r will remain 0 until first bit of input string is 1 so r=0 for string 00000
then r=(0000<<1) OR(1-0) //000001
=0000 OR 0001
=0001
r=(0001<<1) OR(0-0) //0000010
=0010 OR 0000
=0010
r=(0010<<1) OR(1-0) //00000101
=0100 OR 0001
=0101
r=(0101<<1) OR(0-0) //000001010
=1010 OR 0000
=1010
so r=1010 will be returned whose decimal value is 10