mirror of
https://github.com/thunderbrewhq/bc.git
synced 2025-12-12 01:52:30 +00:00
39 lines
640 B
C++
39 lines
640 B
C++
#include "bc/string/Find.hpp"
|
|
|
|
char* Blizzard::String::Find(char* str, char ch, int32_t count) {
|
|
if (!str || !ch) {
|
|
return nullptr;
|
|
}
|
|
|
|
auto ptr = str;
|
|
auto end = str + count;
|
|
|
|
while (ptr != end && *ptr) {
|
|
if (ch == *ptr) {
|
|
return ptr;
|
|
}
|
|
|
|
ptr++;
|
|
}
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
const char* Find(const char* str, char ch, int32_t count) {
|
|
if (!str || !ch) {
|
|
return nullptr;
|
|
}
|
|
|
|
auto ptr = str;
|
|
auto end = str + count;
|
|
|
|
while (ptr != end && *ptr) {
|
|
if (ch == *ptr) {
|
|
return ptr;
|
|
}
|
|
|
|
ptr++;
|
|
}
|
|
|
|
return nullptr;
|
|
}
|