code from hackers delight
<pre><code>/* Converts the unsigned integer k to binary character form with a blank
after every fourth digit.  Result is in string s of length 39.  Caution:
If you want to save the string, you must move it.  This is intended for
use with printf, and you can have only one reference to this in each
printf statement. */
char * binary(unsigned k) {
   int i, j;
   static char s[40] = "0000 0000 0000 0000 0000 0000 0000 0000";

   j = 38;
   for (i = 31; i &gt;= 0; i--) {
      if (k &amp; 1) s[j] = '1';
      else       s[j] = '0';
      j = j - 1;
      k = k &gt;&gt; 1;
      if ((i &amp; 3) == 0) j = j - 1;
   }
   return s;
}
</code></pre>

<p>i have tested  it in c++</p>

<pre><code>#include &lt;iostream&gt;
using namespace std;

char *binary(unsigned k){

    int i, j;
    static char s[40]="0000 0000 0000 0000 0000 0000 0000 0000";
    j=38;
    for (i=31;i&gt;=0;i--){
        if (k &amp; 1) s[j]='1';
        else s[j]='0';
        j=j-1;
        k=k&gt;&gt;1;
        if ((i &amp; 3)==0) j=j-1;
    }
    return s;
}

int main(){

    unsigned k;
    cin&gt;&gt;k;
    *binary(k);

    return 0;
}
</code></pre>

<p>but what value  does k have ? for example i have entered 127 but it return 0 why?</p>
