title: How to split an array in c?
body: <p>I need a logic to acheive my target. I've buffer array size of 38400. This array data can be filled by a controller. Here i have to obtain an AES algorithm. In that i've to read  16 bytes of data from the buffer then encrypt, upto end of buffer. How to spilt an array into 16 bytes and encrypt? . I used following logic but i can't get it right now ? </p>
  
  <pre><code>    unsigned char ptext[16] = "Attack at dawn!";
      unsigned char ctext[16];
      unsigned char decptext[16];
      unsigned char buffer[120*160*2];
  
      for (int count = 0; count &lt; 120*160*2; count ++)
       buffer[count] = count + 1;
  
      for (i = 0; i &lt; 120*160*2; i ++)
  {
  
      ptext[i]= buffer[i];
  
      if(i%15 == 0)
      {
      aes_encrypt(ctx, ptext, ctext);
      for(k = 0; k&lt;=i; k++)
              {
                  ptext[k]='\0';
              }
      }
  }
  
  
   void aes_encrypt(aes_ctx_t *ctx, unsigned char input[16], unsigned char output[16])
   {
      int i;
  
  // copy input to state
  for(i = 0; i &lt; 16; i++)
      ctx-&gt;state[i &amp; 0x03][i &gt;&gt; 2] = input[i];
  
  aes_addroundkey(ctx, 0);
  
  for(i = 1; i &lt; ctx-&gt;rounds; i++) {
      aes_subbytes(ctx);
      aes_shiftrows(ctx);
      aes_mixcolumns(ctx);
      aes_addroundkey(ctx, i);
  }
  
  aes_subbytes(ctx);
  aes_shiftrows(ctx);
  aes_addroundkey(ctx, ctx-&gt;rounds);
  
  // copy state to output
  for(i = 0; i &lt; 16; i++)
  {
      output[i] = ctx-&gt;state[i &amp; 0x03][i &gt;&gt; 2];
      printf("%c",output[i]);
  }
  
  
   }
  </code></pre>
  
  <p>Note: I've filled buffer[] with random numbers.</p>
  
  <p>Me only have to know how to split an array.</p>
  
  <p>Thanks in Advance.</p>