In C ++, STRRCHR () is a predefined function for string manipulation. Cstring is the header file required for string functions.

This function returns a pointer to the last occurrence of a character in the string.

The last character we want to find to occur is passed as the second argument to the function, and we must find the string of that character to pass as the first argument to the function.

syntactic

Char * STRRCHR (const char * STR, int c)

In this case, STR is the string and c is the character to be located. It is passed as an int promotion, but internally converted back to char.

using

Given a string in C ++, we need to look for the last occurrence of the character, let’s say “a”.

Example:

Input: string =’ This is a string ‘output: 9

Input: string =’ my name is Ayush’ output: 12

algorithm

1. Pass the given string in the STRCHR () function and mention the character you need to point to.

2. The function returns a value and prints the value.

Example 1:

Output: 9

Example 2:

Output:

String after last e is : eks

String after last m is : (null)

Practical use: Since it returns the entire string after the last occurrence of a particular character, it can be used to extract the suffix of a string. For example, when we know the first number, know the entire leading zeros in a denomination. This example is shown below.

Output:

The original string is: 10000000

The denomination value is: 10000000

Hope to help you ~

In addition, if you want to improve your programming ability, learn C language C++ programming! Pass on the curve, one step faster! The author here may be able to help you ~

C/C++QQ Learning group

Wechat official account: C language programming Learning base

Share (source code, project actual combat video, project notes, basic introduction tutorial)

Welcome to change careers and learn programming partners, use more information to learn and grow faster than their own thinking oh!

Programming learning books:

Programming learning video sharing: