//Ö¸ÕëÇó×Ö·û´®³¤¶ÈµÄº¯Êý£¬Ò²¾ÍÊÇÇó×Ö·û´®µÄ¸öÊý£¬¸Ã¹¦Äܲ»°üÀ¨×Ö·û´®'\0'£¬¶ø×Ö·û´®µÄ //½áÊø£¬¾ÍÊÇ'\0'×÷Ϊ½áÊø·û int str_len(char *str) { int i = 0;
while(*str) { i++; str++; }
return i; }
char * str_cpy(char *str,const char *buf) { char *st = str;
if(str == NULL || buf == NULL) return NULL;
while(*buf) { *str = *buf; str++; buf++; } *str = '\0';
return st; }
char *str_cat(char *str,const char *buf) { char *st = str;
if(str == NULL || buf == NULL) return NULL;
while(*str) { str++; } while(*buf) { *str = *buf; str++; buf++; } *str = '\0';
return st; }
int str_cmp(const char *buf,const char *str) { if(str == NULL || buf == NULL) return NULL;
while(*buf || *str) { if(*buf > *str) return 1; else if(*buf < *str) return -1; buf++; str++; }
return 0; } |