zoukankan      html  css  js  c++  java
  • strpbrk函数

    函数原型:extern char *strpbrk(char *str1, char *str2)

    参数说明:str1待比较的字符串,str2为指定被搜索的字符串。
            
    所在库名:#include <string.h>
      
    函数功能:比较字符串str1和str2中是否有相同的字符,如果有,则返回该字符在str1中的位置的指针。
      
    返回说明:返回指针,搜索到的字符在str1中的索引位置的指针。

    其它说明:暂时无。

    实例:

    #include<string.h>
    #include
    <stdio.h>
    int main()
    {
        
    char *str1="please try again,sky2098!";
        
    char *str2="Hello,I am sky2098,I like writing!";
        
    char *strtemp;
        strtemp
    =strpbrk(str1,str2);  //搜索进行匹配
        printf("Result is:  %s ",strtemp);
        
    return 0;
    }

    在VC++ 6.0  编译运行:

    返回了str2中字符“l”在str1中位置的指针,打印出字符串“lease try again,sky2098!”。

    如果str2中所有字符都没有在str1中出现过,则返回null:

    #include<string.h>
    #include
    <stdio.h>
    int main()
    {
        
    char *str1="aaaaaaabbbbbbbcccccccc";  //str1中的任何一个字符在str2中都找不到
        char *str2="ppppkkkkmmmer";
        
    char *strtemp;
        strtemp
    =strpbrk(str1,str2);
        printf(
    "Result is:  %s ",strtemp);
        
    return 0;
    }

    在VC++ 6.0  编译运行:

    返回了空值。

  • 相关阅读:
    逻辑回归(logistics regression) 总结
    SQL注入原理
    xss绕过过滤之方法
    PHP CALC
    IP欺骗原理与过程分析
    DNS域传送漏洞利用
    linux性能测试工具perf
    linux设置程序开机自启
    Http请求中Content-Type和Accept讲解以及在Spring MVC中的应用
    random函数的使用
  • 原文地址:https://www.cnblogs.com/lgh1992314/p/5835364.html
Copyright © 2011-2022 走看看