I wanted to have a look at the implementation of different C/C++ functions (like strcpy, stcmp, strstr). This will help me in knowing good coding practices in c/c++. Could y
Look at an implementation of the libc standard C library. To see how a real, popular C library is implemented, try looking at the glibc code. You can access the code using git:
git clone git://sourceware.org/git/glibc.git
As for C++, you can find the glibc++ standard library on one of these mirrors:
http://gcc.gnu.org/mirrors.html
You can also check out uLibc, which will probably be simpler than the GNU library:
http://git.uclibc.org/uClibc/tree/
To give you a flavour, here's the strncpy implementation from uLibc:
Wchar *Wstrcpy(Wchar * __restrict s1, const Wchar * __restrict s2)
{
register Wchar *s = s1;
#ifdef __BCC__
do {
*s = *s2++;
} while (*s++ != 0);
#else
while ( (*s++ = *s2++) != 0 );
#endif
return s1;
}
Here is strcmp and strstr