diff options
Diffstat (limited to 'lib/String.cc')
-rw-r--r-- | lib/String.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/String.cc b/lib/String.cc index bd265a0..75d9d15 100644 --- a/lib/String.cc +++ b/lib/String.cc @@ -331,6 +331,18 @@ char String::operator[](size_t i) const { } } +char & String::operator[](size_t i) { + static char zero; + + zero = 0; + + if (i >= siz) { + return zero; + } else { + return str[i]; + } +} + ssize_t String::strchr(char c, size_t from) const { for (size_t i = from; i < siz; i++) { if (str[i] == c) return i; |