MEMSEARCHR
MEMSEARCHR returns a size_t 1 value that specifies the first position (from the right) in a buffer at which any character, graphic, uchar, or widechar in a given string appears.
- p
- Address of buffer to be searched
- n
- Length of buffer to be searched
- x
- String-expression
The buffer length must be nonnegative and must have a computational type. The buffer length is converted to type size_t.
The string-expression x must have type CHARACTER (including PICTURE), GRAPHIC, UCHAR, or WIDECHAR. The buffer length is interpreted as the number of units of that string type.
The address p and the length n specify the "string" in which to search for any character, graphic, uchar, or widechar that appears in x.
If either the buffer length n is zero or x is the null string, the result is zero.
If x does not occur in the buffer, the result is zero.
Example
dcl cb(128*1024) char(1);
dcl wb(128*1024) widechar(1);
dcl pos fixed bin(31);
/* 128K bytes searched from the right for a numeric */
pos = memsearchr( addr(cb), stg(cb), '012345789' );
/* 256K bytes searched from the right for a widechar '0' or '1' */
pos = memsearchr( addr(wb), stg(wb), '0030_0031'wx );