b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

c strcpy用法_c strchr函数用法_indexofstring c 实现(19)

电脑杂谈  发布时间:2017-02-28 02:04:31  来源:网络整理

ptr=strcmp(buf2, buf3);

if(ptr>0)

printf("buffer 2 is greater than buffer 3/n");

else

printf("buffer 2 is less than buffer 3/n");

return 0;

}

@函数名称: strncmp

函数原型: int strncmp(char *str1,char *str2,int count)

函数功能: 对str1和str2中的前count个字符按字典顺序比较

函数返回: 小于0:str1str2

参数说明: str1,str2-待比较的字符串,count-比较的长度

所属文件:

#include

#include

int main()

{

int ptr;

char *buf1="aaabbb",*buf2="bbbccc",*buf3="ccc";

ptr=strncmp(buf2,buf1,3);

if (ptr>0)

printf("buffer 2 is greater than buffer 1");

else

printf("buffer 2 is less than buffer 1");

ptr=strncmp(buf2,buf3,3);

if (ptr>0)

printf("buffer 2 is greater than buffer 3");

else

printf("buffer 2 is less than buffer 3");

return(0);

}

@函数名称: strpbrk

函数原型: char *strpbrk(const char *s1, const char *s2)

函数功能: 得到s1中第一个“同时也出现在s2中”字符的位置指针

函数返回: 位置指针

参数说明:

所属文件:

int main()

{

char *p="Find all vowels";

while(p)

{

printf("%s/n",p);

p=strpbrk(p+1,"aeiouAEIOU");

}

return 0;

}

@函数名称: strcspn

函数原型: int strcspn(const char *s1, const char *s2)

函数功能: 统计s1中从头开始直到第一个“来自s2中的字符”出现的长度

函数返回: 长度

参数说明:

所属文件:

int main()

{

printf("%d/n",strcspn("abcbcadef","cba"));

printf("%d/n",strcspn("xxxbcadef","cba"));

printf("%d/n",strcspn("123456789","cba"));

return 0;

}

@函数名称: strspn

函数原型: int strspn(const char *s1, const char *s2)

函数功能: 统计s1中从头开始直到第一个“不来自s2中的字符”出现的长度

函数返回: 位置指针

参数说明:

所属文件:

int main()

{

printf("%d/n",strspn("out to lunch","aeiou"));

printf("%d/n",strspn("out to lunch","xyz"));

return 0;

}

@函数名称: strchr

函数原型: char* strchr(char* str,char ch);


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-34906-19.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    • 华国锋
      华国锋

      现在需要探讨的是对美斗争的策略

    每日福利
    热点图片
    拼命载入中...