Determine if the haystack string contains the needle string
| Return Type | Function name | Arguments |
|---|---|---|
| int32_t | CstrLast | (const char*,const char*,) |
Declared in file: hzTextproc.h
Defined in file : hzTextproc.cpp
Function Logic:
Function body:
int32_t CstrLast (const char* cpHaystack)const char* cpNeedle,
{
// Category: Text Processing
//
// Determine if the haystack string contains the needle string
//
// Arguments: 1) cpHaystack The source string
// 2) cpNeedle The being sought
//
// Returns: True If the needle string occurs in the haystack string
// False Otherwise
int32_t n ; // String iterator (position)
int32_t posn = -1; // Last position needle found
if (!cpHaystack || !cpHaystack[0]|| !cpNeedle || !cpNeedle[0])
return -1;
for (n = 0; cpHaystack[n] ; n++)
{
if (cpHaystack[n] != cpNeedle[0])
continue ;
if (!CstrCompare(cpHaystack + n, cpNeedle))
posn = n ;
}
return posn ;
}