MQL4参考 字符串函数 StringSetChar

StringSetChar

Returns the string copy with changed character in the specified position.

string  StringSetChar(
   string    string_var,       // string
   int       pos,              // position
   ushort    value             // char code
   );

Parameters

string_var

[in]  Source string.

pos

[in]  The character position in the string. Can be from 0 to StringLen(text).

value

[in]  New char ASCII-code.

Returned value

The string copy with changed character in the specified position.

Note

If the value of pos parameter is less than string length and char code = 0, the string will be truncated (to position, equal to pos). If the value of pos parameter is equal to string lenth, the specified symbol will be added to the end of the string and string length will be increased by 1.

Example:

  string str="abcdefgh";
  string str1=StringSetChar(str, 3, 'D');
  // str1 = "abcDefgh"

See also

StringBufferLen(), StringLen(), StringFill(), StringInit()