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

strchr函数_c find函数返回值_strncpy函数用法

电脑杂谈  发布时间:2017-01-30 22:14:44  来源:网络整理
strchr函数strchr函数

#include <iostream>

using namespace std;

// 自己实现strchr函数

char * Strchr(char to[], char Ch);

int main()

{

char to[30], ch, *p;

cout << "请输入字符串:";

cin >> to;

cout << "请输入一个字符:";

cin >> ch;

p = Strchr(to, ch);

if (p != NULL)

cout << "第一个开始匹配后的字符串是:" << p << endl << "在数组的第【" << p - to 1 << "】个位置" << endl;

else

cout << "没有匹配的字符!" << endl;

system("pause");

return 0;

}

char * Strchr(char to[], char Ch)

{

int i = 0;

while (to[i] != Ch && to[i] != '\0')

i;

return to[i] != '\0' ? to i : NULL;

}


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

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

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