strwalk()
The function allows to move through a string and returns the corresponding character of a specific position.
Synopsis
string strwalk(string s, int &pos);
Parameters
Parameter | Description |
---|---|
s | String to be read. |
&pos | Position of the character that should be read. Starts with an index of 0. |
Return value
Returns the character from the position inside of the stated string. If no character can be found an empty string is returned.
Errors
Wrong or missing parameters.
Description
The function allows to access a specific character inside of the stated string and returns it as the functions return value. The stated position parameter (pos) is updated and changed to the position of the next character inside of the string.
When using an UTF8 encoded string a 4-byte UTF8 character is returned. If a non UTF8 encoded string is used only a single byte character is returned.
Example
In the example below the function strwalk() reads the character on the first position (myInt) of the stated string (myStr). The character "T" is returned and the position (myPos) is updated to the position of the next character (=1).
main()
{
string myStr = "This is my string value!";
int myInt = 0;
DebugN(strwalk(myStr, myInt));
DebugN(myInt);
}
Assignment
Strings
Availability
CTRL