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

Strchr函数的实现和简单的应用

电脑杂谈  发布时间:2020-04-04 20:09:26  来源:网络整理

c strchr函数_strchr函数怎么用_c strchr函数

//: Vc ++ 6.0 Stringstrchr函数

//功能: 首次查找字符c在字符串s中的位置

//参数: str是目标字符串c是要找到的字符

//返回值: str是找到第一个字符的地址

#include

const char * strchr(const char * strc strchr函数,int c);

c strchr函数_strchr函数怎么用_c strchr函数

int主(无效)

{

char * str =“ hello world”;

printf(“%d \ n”,strchr(str,'e')-str);

返回0;

}

c strchr函数_strchr函数怎么用_c strchr函数

const char * strchr(const char * str,int c)

{

如果(str == NULL)

{

perror(“ str”);

返回NULL;

c strchr函数_strchr函数怎么用_c strchr函数

}

同时(* str!='\ 0')

{

if(* str!=(char)c)//强制c的值为字符

{

str ++;

strchr函数怎么用_c strchr函数_c strchr函数

}

其他

return str;

}

返回NULL;

}

//在vc ++ 6.0中运行结果为: 1

//注意: 使用时要注意返回值

//为什么参数是int类型?

//这是历史原因. 很久以前,还没有C语言的函数原型c strchr函数


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

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

      热点图片
      拼命载入中...