From: Jeremy Potter Date: Fri, 17 Apr 2020 21:14:38 +0000 (+0000) Subject: Add strtoupper() and strtolower() and improve description of substring() X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=71e7893c5f6527fbb0fbfbfb69e5fe24f7e7937c;p=xonotic%2Fxonotic.wiki.git Add strtoupper() and strtolower() and improve description of substring() --- diff --git a/Introduction-to-QuakeC.md b/Introduction-to-QuakeC.md index 0cd22f1..aaa5fe2 100644 --- a/Introduction-to-QuakeC.md +++ b/Introduction-to-QuakeC.md @@ -150,14 +150,19 @@ A *string* in QuakeC is an immutable reference to a null-terminated character st strstrofs("haystack", "ac", 0) == 5; ``` +The offset defines from which starting position to search, and the return value is `–1` if no match is found. The offset returned is *0*-based, and to search in the whole string, a start offset of *0* would be used. + - **strreplace(old, new, string)** searches for certain characters in a string and replaces them with other characters, as in: ```c strreplace("de", "con", "destruction") == "construction"; ``` -The offset defines from which starting position to search, and the return value is `–1` if no match is found. The offset returned is *0*-based, and to search in the whole string, a start offset of *0* would be used. +- **substring(string, startpos, length)** returns part of a string. + +The offset is *0*-based here, too. A length of `-1` designates the end of the string (it will return the part of the string after the start position), a length of `-2` designates the penultimate character of the string, and so on. -- **substring(string, startpos, length)** returns part of a string. The offset is *0*-based here, too. +- **strtoupper(string)** capitalizes a string. +- **strtolower(string)** lowercases a string. Note that there are different kinds of *strings*, regarding memory management: