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

strstr函数的用法_c find函数返回值_strchr函数(4)

电脑杂谈  发布时间:2017-01-31 04:07:50  来源:网络整理

The terminating '\0' characters are not compared.

The strcasestr() function is like strstr(), but ignores the case of both arguments.

* RETURN VALUE

These functions return a pointer to the beginning of the substring, or NULL if the substring is not found.

*/

    char *pRetval = strstr( (char *)pSrc, pDst);
    printf("[%s]-[%d] pRetval = %s \n", __func__, __LINE__, pRetval);
/* 个人理解: 在源字符串中需找目标字符串,如果源字符串中存在,

则返回出现目标字符串的首地址,不存在,则返回空

对大小写字母敏感(区分大小写)*/

    pRetval = strcasestr( (char *)pSrc, pDst );
    printf("[%s]-[%d] pRetval = %s \n", __func__, __LINE__, pRetval);

/* 个人理解: 在源字符串中需找目标字符串,如果源字符串中存在,

则返回出现目标字符串的首地址,不存在,则返回空

对大小写字母不敏感(忽略大小写)*/

   
    return 0;
}

3 strchr strrchr,

在字符串中查找对应ASCII码为对应正数的字节,前面函数返回第一次查找到,后面函数返回最后一次查找到

int main (void )
{

/* NAME

strchr, strrchr, -locate character in string

SYNOPSIS

#include <string.h>

char *strchr(const char *s, int c);

char *strrchr(const char *s, int c);

DESCRIPTION

The strchr() function returns a pointer to the first occurrence of the character c in the string s.

The strrchr() function returns a pointer to the last occurrence of the character c in the string s.

RETURN VALUE

The strchr() and strrchr() functions return a pointer to the matched character or NULL if the character is not found.

*/

    const char *pSrc = "xxxxbooooobwbppppppbcccccccc";
    
    char *pRetval = strchr((char*)pSrc, 98);
    printf("[%s]-[%d] pRetval = %s \n", __func__, __LINE__, pRetval);

/* 个人理解:在目标字符串中,从字符串开头开始查找对已ASCII码为98的字节,


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

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

    • 卢伟
      卢伟

      铁汉柔情

    • 陶晓艳
      陶晓艳

      幸亏市场上很多货在卖不然小米不好找借口

      • 郭恭
        郭恭

        高铁中国在和日本竞争订单吧

    • 张子轩
      张子轩

      这种东西还用酿吗

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