Guest User

C++ nizovi

a guest
Jun 13th, 2012
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.34 KB | None | 0 0
  1. char* strncat1(char* s1, char* s2, int n)
  2. {
  3.     char* temp;
  4.     int temp_index;
  5.     temp = new char [n];
  6.     for(int i=0; i<n; i++)
  7.     {
  8.         if(s2[i]!='\0')
  9.         {
  10.             temp[i]=s2[i];
  11.         }
  12.     }
  13.  
  14.     for(int i=0; s1!='\0'; i++)
  15.     {
  16.         if(s1[i] == '\0')
  17.         {
  18.             temp_index=i;
  19.         }
  20.     }
  21.  
  22.     for(int i=temp_index; i<n; i++)
  23.     {
  24.         s1[i]=temp[i];
  25.     }
  26.  
  27.     return s1;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment