Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

How to copy one string into another in C

char *
strncpy(char *dest, const char *src, size_t n)
{
    size_t i;

   for (i = 0; i < n && src[i] != ''; i++)
        dest[i] = src[i];
    for ( ; i < n; i++)
        dest[i] = '';

   return dest;
}
Source by linux.die.net #
 
PREVIOUS NEXT
Tagged: #How #copy #string #C
ADD COMMENT
Topic
Name
5+2 =