title: Buffers with pointers in C
body: <p>I am confused about a basic C thing here.
  I have a buffer of 36 bytes. And I want to write 3 data bytes to that buffer, each of 12 bytes received from diiferent functions.
  For simple (may not be efficient) way, what I have done is, I have taken 3 different buffers of 12 bytes each. And using memcpy() I write data into those buffers. And then I use a strcat function to get them into the 35-byte buffer.
  Is there any other way of doing it?</p>
  
  <pre><code>int main()  
  {  
      typedef struct rtc_time_type{  
          int HOUR;  
          int MIN;  
          int SEC;  
      }RTC_TIME_Type;  
  
      RTC_TIME_Type pCurrentTime;  
  
      char mainbuff[36], buff1[12], char buff2[12], char buff3[12];  
  
      memset(mainbuff,0,36);  
      memset(buff1,0,12);  
      memset(buff1,0,12);  
      memset(buff1,0,12);  
  
      memcpy(buff1, /*int bytes received from some structure*/ pCuurentTime.HOUR);  
      memcpy(buff2, /*int bytes received from some structure*/ pCuurentTime.MIN);  
      memcpy(buff3, /*int bytes received from some structure*/ pCuurentTime.SEC);  
  
      strcat(mainbuff,buff1);  
      strcat(mainbuff,buff2);  
      strcat(mainbuff,buff3);  
  
      //send mainbuff on UART  
      UART_Tx_Buff(mainbuff);  
  
      return 0;  
  
  }  
  </code></pre>