#include#include #include char* strcpy(char * destination, const char * source ); char* strcat ( char * destination, const char * source ); int strcmp ( const char * str1, const char * str2 ); int mystrncmp( const char *string1, const char *string2, size_t count ); char* mystrncpy( char *strDest, const char *strSource, size_t count ); char* mystrncat( char *strDest, const char *strSource, size_t count ); //字符串拷贝函数 char* mystrcpy(char* destination,const char*source){ assert(destination!=NULL&&source!=NULL); char* dest=destination; const char* src=source; while(*src!=' '){ *dest++=*src++; } *dest=*src; return destination; } //字符串连接函数 char* mystrcat(char*destination,const char*source){ assert(destination!=NULL&&source!=NULL); char* dest=destination; const char * src=source; while(*dest!=' '){ dest++; } while(*src!=' '){ *dest++=*src++; } *dest=*src; return destination; } //字符串大小比较函数 int mystrcmp(const char *destination,const char* source){ assert(destination!=NULL&&source!=NULL); while(*destination!=' '||*source!=' '){ if((*destination-*source)!=0) break; destination++; source++; } return *destination-*source ; } //n个字符串比较 int my_strncmp( const char *string1, const char *string2, size_t count ) { assert(string1!=NULL && string2!=NULL); while(count-- != 0) { if(*string1 - *string2 != 0) break; string1++; string2++; } if(count==0) return *--string1 - *--string2; else return *string1-*string2; } //拷贝n个字符 char* mystrncpy( char *string1, const char *string2, size_t count ){ assert(string1!=NULL&&string2!=NULL); char* dest=string1; const char* src=string2; while(count--!=0){ *dest++=*src++; } return string1; } //连接n个字符 char* mystrncat( char *string1, const char *string2, size_t count ){ assert(string1!=NULL&&string2!=NULL); char* dest=string1; const char*src=string2; while(*dest!=' '){ dest++; } while(count--!=0){ *dest++=*src++; } *dest=' '; return string1; }



