zoukankan      html  css  js  c++  java
  • C语言之strrchr函数

    FROM MSDN && 百科】

    原型:char *strrchr(const char *str, char c);

    #include<string.h>

    找一个字符c在另一个字符串str中末次出现的位置(也就是从str的右侧开始查找字符c首次出现的位置),并返回从字符串中的这个位置起,一直到字符串结束的所有字符。如果未能找到指定字符,那么函数将返回NULL。

    The strrchr function finds the last occurrence of c (converted to char) in str. The search includes the terminating null character.


    DEMO:

        #include <stdio.h>
        #include <conio.h>
        #include <string.h>
        #pragma warning (disable:4996)
        int main(void)
        {
            char string[20];
            char *ptr;
            char c='r';
            strcpy(string,"There are two rings");
            ptr=strrchr(string,c);
            //ptr=strchr(string,c);
            if (ptr!=NULL)
            {
                printf("The character %c is at position:%s ",c,ptr);
            }
            else
            {
                printf("The character was not found ");
            }
            getch();
            return 0;
        }
    ---------------------
    作者:hou_sky
    来源:CSDN
    原文:https://blog.csdn.net/hgj125073/article/details/8443912
    版权声明:本文为博主原创文章,转载请附上博文链接!

  • 相关阅读:
    ajax获取后台数据,显示到input输入框里面
    js的比较运算符含义和示例和逻辑运算符
    Vue的 on +bind+if +for
    Vue入门例子
    Spring-AOP
    fatal: remote origin already exists git出现这个
    springmvc-文件上传下载
    springmvc-ajax
    查询Id最大的基础上+1
    bootstrap select去掉右边小三角
  • 原文地址:https://www.cnblogs.com/yanzi-meng/p/10172999.html
Copyright © 2011-2022 走看看