正在加载图片...
4)串比较(compare) int strcmp(char *s1,char *s2); 该函数比较串s1和串s2的大小,当返回值小于0, 等于0或大于0时分别表示s1<s2八s1=s2或s1>s2 例如:result=:strcmp(“baker'”,”Baker')result>0 result=strcmp(“12”,”12");result=0 result=strcmp(“Joe",”Joseph");result<0 (5)字符定位(index) char strchr(char *s,char *c); 该函数是找c在字符串s中第一次出现的位置,若 找到则返回该位置,否则返回NULL。 例如:p=strchr(s2,”.”);p指向“file”之后的位置 if(p)strcpy(p,”.cpp");s2=“file.cpp” (4)串比较(compare) int strcmp(char *s1,char *s2); 该函数比较串s1和串s2的大小,当返回值小于0, 等于0或大于0时分别表示s1<s2\s1=s2或s1>s2 例如:result=strcmp(“baker”,”Baker”) result>0 result=strcmp(“12”,”12”); result=0 result=strcmp(“Joe”,”Joseph”); result<0 (5)字符定位(index) char strchr(char *s,char *c); 该函数是找c在字符串s中第一次出现的位置,若 找到则返回该位置,否则返回NULL。 例如:p=strchr(s2,”.”); p 指向“file”之后的位置 if(p) strcpy(p,”.cpp”); s2=“file.cpp
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有