Tuesday, February 7, 2012

Own Versions of String Library Functions -II

Implement the following functions
1.memcpy
2.memmove
3.memcmp
4.memchr
5.memset

Other Relevant functions
1.strcspn
2.strpbrk
3.strspn
4.strstr
5.strtok
6.strcoll

memcpy( ):

 void memcpy(void* src, void* dst, size_t len)
{
    char* p = (char*)src;
    char* q = (char*)dst;
    while(len--)
    *p++ = *q++;
}

Useful Links:
http://en.wikibooks.org/wiki/C_Programming/Strings#Copying_functions

No comments:

Post a Comment