title: I can't manipulate bit fields in C
body: <p>I wanted to implement LFSR(linear feedback shift registers) in C to generate random bits. When I try to modify an individual bit or just assign a short value to memory block, all the bits set to 1. How can I stop this from happening?</p>
  
  <pre><code>struct lfsr{
      //... 
      union{
          unsigned short ff_0 : 1;
          unsigned short ff_1 : 1;
          //... 
          unsigned short ff_f : 1;
          unsigned short ff;
      }flip_flops;
  };
  
  int main() {
      struct lfsr gen;
      gen.flip_flops.ff = 1;      //all the ff's set to 1
      gen.flip_flops.ff = htons(0x0001);//all the ff's set to 1
      gen.flip_flops.f_0 = 1;     //all the ff's set to 1
      gen.flip_flops.f_0 = 0;     //all the ff's set to 0
  }
  </code></pre>