Step: Brief discussion : strchr() locates the first character in
a string
![](string86.jpg)
![](string87.jpg)
Checking on "str2.find_first_of("X-Ray")" and str.find()
functions :
Debug with F8 step-over: I have set a break point at a variable
declaration, chptr1 and decided to watch other two variables. The
purpose of this example remain focused to our objectives to
understand difference between a string and character sequence.
![](string88.jpg)
As you would note that, string object str2 refers to a function
npos; meaning npos is a static member constant of "string class"
that determines the greatest possible value for an element of type
size_t. Here, size_t is an unsigned integer meaning, it will get the
positive values, using this grammer " strLength1
=str2.find("First");". You will note that reference "npos" and
assigned values are referenced during the debugging steps.
Reference : (
http://www.cplusplus.com/reference/string/string/npos/ ) " This
constant is actually defined with a value of -1 (for any
trait), which
because size_t is an unsigned integral type, becomes the
largest possible representable value for this type."
At line number 14, the integer variable becomes "n1:=-1", which
proves the above reference statement.
![](string89.jpg)
Note the match was found at 11th position, and the length of that
matched string was 5 character long.
![](string90.jpg)
The illustration below shows the value of n1 which was expected
show the beginning of ,string like"X-Ray" or "X-string"
![](string91.jpg)
Now note, the value of n1 changed with our request.
![](string92.jpg)
Checking on strchr() function:
![](string93.jpg)
![](string94.jpg)
Conclusion : This example shows the uses of string::find(),
string:: find_first_of("X-man") and chptr1 = strchr(chstr1, 'e').
Using together we can get to the string or to an individual
character, and it is not the end of the road. There are many ways to
accomplish the above task.