Tuesday 11 December 2012

Implement strncat

/*This function will append "n" character of source string "src" into target string "tar" & return Zero. */

char *mystrncat(char *tar, const char *src, int n)

{

char *t;/*retaing the address of target string*/

t = tar ;

while (*tar != '\0')

tar++;

/*Copying from src to tar string*/

while (*src != '\0' && (*tar++ = *src++) && (--n > 1));

*tar = '\0';

return t;

}

No comments:

Post a Comment