This returns the position of the first instance of c in str. It has the advantage that it won't crash when given duff input
| Return Type | Function name | Arguments |
|---|---|---|
| int32_t | CstrFirst | (const char*,char,) |
Declared in file: hzTextproc.h
Defined in file : hzTextproc.cpp
Function Logic:
Function body:
int32_t CstrFirst (const char* cpStr)char testChar,
{
// Category: Text Processing
//
// This returns the position of the first instance of c in str. It has the advantage that it won't crash when given duff input
//
// Arguments: 1) cpStr The string to test
// 2) testChar The char to test for
//
// Returns: -1 If the test char does not appear in the string
// 0+ Being the position of the first occurence of the test char in the string
int32_t nPosn = 0; // Input string position
if (!cpStr || !cpStr[0]|| !testChar)
return -1;
for (nPosn = 0; cpStr[nPosn] ; nPosn++)
{
if (cpStr[nPosn] == testChar)
return nPosn ;
}
return -1;
}