Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. /* strncat( char *, const char *, size_t )
  2.  
  3.    This file is part of the Public Domain C Library (PDCLib).
  4.    Permission is granted to use, modify, and / or redistribute at will.
  5. */
  6.  
  7. #include <string.h>
  8.  
  9. char * strncat( char * s1, const char * s2, size_t n )
  10. {
  11.     char * rc = s1;
  12.  
  13.     while ( *s1 )
  14.     {
  15.         ++s1;
  16.     }
  17.  
  18.     while ( n && ( *s1++ = *s2++ ) )
  19.     {
  20.         --n;
  21.     }
  22.  
  23.     if ( n == 0 )
  24.     {
  25.         *s1 = '\0';
  26.     }
  27.  
  28.     return rc;
  29. }