All pastes #939534 Raw Edit

agilman

public text v1 · immutable
·published 2008-03-12 11:21 UTC
rendered paste body
#include <stdio.h>
/*my_strncat concatinates at most n characters of t to s */
void my_strncat(char *s, char *t, int n)
{  
   char *temp;
   temp = s;
   for(;*temp!='\0';temp++)
     ;

   int i;
   for(i=0;i<n;i++){
      *(temp+1) = *(t+1);
      *temp++;
      *t++;

   }

   s= temp;
   printf("%s\n", s);
}


int main()
{
   char charbuf[20]="abcdef";

   char *a = charbuf;
   char *b = "12345";
   
   my_strncat(a, b, (int) 2);

   return 0;
}