strstr 函数介绍

来源:互联网 发布:电缆分层算法 编辑:程序博客网 时间:2024/06/07 06:36

今天突然看到一个以前从来没有用过的函数 strstr ,真是菜,在字符串中找子字符串都是用的string ....

原型是

_CONST_RETURN char *__cdecl strstr(const char *_Str,const char *_SubStr);


__cdecl 的应该是 函数的调用约定,好像是规定函数返回时某些动作应该由谁来做。具体的以后深入了解写点东西记录一下。

#include <iostream>#include <stdio.h>#include <string.h>using namespace std;int main(){char a[30]="hello world";char b[5]="wo";cout<<strstr(a,b)<<endl;return 0;} 
函数的运行结果是 world

0 0