-
-
Notifications
You must be signed in to change notification settings - Fork 18
string_char_at
Matěj Štágl edited this page Dec 15, 2018
·
7 revisions
Checks a given string and returns the character at a given position.
string_char_at(str, index);
Argument | Description |
---|---|
string str |
The string to check. |
int index |
The position to get the character from. |
Returns: char
You can use this function to return a specific character at a specific position within a string, with the index starting at 1 for the first character. If no character is found or the string is shorter than the value given to index, an empty string "" is returned.
string str1 = "Hello World";
char chr = string_char_at(str1, 7);
This will set str2 to the seventh character ("H" counting as the 1st) in string str1, in this case "W".
Back to strings