-
|
I was wondering why bother creating a AreStringsEqualRuntime func that takes in 2 C-strings and their lengths? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
I did that because this function is intended to be used for seeing if 2 strings at runtime are equal. So, these could be strings created by something during runtime where at runtime we would know what the length of those strings are. |
Beta Was this translation helpful? Give feedback.
I did that because this function is intended to be used for seeing if 2 strings at runtime are equal. So, these could be strings created by something during runtime where at runtime we would know what the length of those strings are.
Since they're just C-strings (presumably null-terminated) we need something to say where those strings end i.e. where their last valid element is, that is the Count param for each string respectively.
Passing in the count can saves a lot of time in the first step of checking whether the lengths are the same, because if they're not then it's impossible that the strings are the same.