The lstrcpyn (alias strncpy) function copies a specified number of characters from a source string into a buffer.
LPSTR lstrcpyn( LPSTR lpString1, LPCSTR lpString2, int iMaxLength )
If the function succeeds, the return value is a pointer to the buffer. If the function fails, the return value is NULL.
EX1
void lstrcpyn_ex1() { char *ptr = NULL; char szStr[80]; string str1 = "Here is some text"; ptr = lstrcpyn(szStr, str1, 5); if(0 == strcmp(ptr, "Here") ) printf(" after copy szStr is \"%s\" \n" , szStr); else printf("copy failed\n"); }
lstrcpy
origin.h