#include #include #include / * implement library functions Strncpy, Strncat, Strncmp, which operates the previous N characters in the parameter string. Char * STRNCPY (Char * DEST, Const Char * SRC, INT Count) Copy the count character in the string SRC to the string DEST to the DEST destination string, SRC source string, count copy of the character number DEST is equal to the SRC COUNT character content, returning pointer Char * strncat (char * dest, const char * src, size_t maxlen) to dest in the DEST INT STRNCMP (Char * STR1, CHAR * STR2, INT count, str2 string to be compared, COUNT compares less than 0: str1 str2 * / char * ustrncpy (char * dest, const char * src) , int count) {char * pd = dest; int N; if ((n = strlen (src))
While (count-> 0) * DEST = * src ; * dest = '/ 0'; return pd;} char * ust, const char * src, int maxlen) {char * pd = DEST; int; int n; if (Maxlen> (N = Strlen (src))) Return NULL;
While (* DEST! = '/ 0') DEST ; while (maxlen-> 0) * DEST = * src ; * dest = '/ 0'; return pd;} int ustrncmp (char * str1, char * str2, INT count) {while (count-> 0) {if (* str1! = '/ 0' && * str2! = '/ 0') {if (* str1! = * str2) Return * STR1- * STR2; STR1 ; str2 ;}}} return (* - str1 - * - str2);} int main (void) {char A [1000] = {"AAAIOFJDFKJASKDLF"}; char b [100] = {"aaa"}; Printf ("% D", 'W' - 'A'); Printf ("% D", USTRNCMP (B, A, 5)); return 0;}