The difference between my strncpy and the strncpy in the Library # include <stdio.h> #define CHAR char#define ULONG unsigned longchar *vos_strncpy (char * Pcdest, const char *SZSRC, ULONG ullength) {CHAR *pcpoint = pcdest;//The pointer is sentenced to NULL if (NULL = = szsrc) | | (NULL = = pcdest)) {return NULL;} while (ullength && (*pcpoint = *szsrc)) {pcpoint++;szsrc++;ullength--;} The difference is, if you copy the original string and there is something in the back put a '!ullength ' if {*pcpoint = ';} return pcdest;} int main () {CHAR szstrbuf[] = "1234567890"; CHAR szstrbuf1[] = "1234567890"; strncpy (Szstrbuf, "abc", STRLEN ("abc")); vos_strncpy (SZSTRBUF1, "abc", STRLEN ("abc"));p rintf ("Str1 =%S\NSTR2 =%s\n", Szstrbuf, SZSTRBUF1); return 0;}
The difference between the strncpy of "C language" and the strncpy in the library