c语言题
/********字符串逆序函数************/ char *Reverse(char *src) { int len; assert(NULL!=src); len=strlen(src); char *address=NULL; char *dst=(char*)malloc(len+1); address=dst; while(len--) { *dst++=src[len]; } *dst='\0'; return address; } /*********求字符串长度**********/ int str_len(char *src) { int len=0; assert(NULL!=src); while(*src++) { ++len; } return len; } /*********比较两个字符串大小**********/ int str_cmp(char *s1,char *s2) { int flag; assert((*s1!='\0') && (*s2!='\0')); while(*s1 && *s2 && (*s1==*s2)) { s1++; s2++; } if(*s1-*s2>0) flag=1; else if(*s1-*s2==0) flag=0; else flag=-1; return flag; } /*********字符串复制*********/ char *str_cpy(char *dst, char *src) { char *address=dst; assert((dst!=NULL) && (src!=NULL)); while(*src) { *dst++=*src++; } *dst='\0'; return address; } /*********字符串连接***********/ char *str_cat(char *dst, char *src) { char *address=dst; assert((dst!=NULL) && (src!=NULL)); while(*dst) { dst++; } while(*src) { *dst++=*src++; } *dst='\0'; return address; }
相关推荐
lynjay 2020-06-14
88384957 2020-06-12
zuihaobushi 2020-04-30
xiaohouye 2020-04-20
菇星獨行 2020-04-20
qscool 2020-04-16
Joymine 2020-03-04
CosEmon 2020-03-01
GoatSucker 2020-02-15
Joymine 2020-02-11
twater000 2020-02-01
徐建岗网络管理 2020-07-28
AaronPlay 2020-06-13
yaneng 2020-04-29
ILVNMM 2020-10-26
PinkBean 2020-08-19
Seandba 2020-08-16
herohope 2020-06-10
adwen00 2020-06-09