//+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { //--- 要转换的字符串 string text = "This is a test of the StringToCharArray() function"; //--- 根据设置的代码页将输入字符串转换为uchar数组 uchar char_array[]; int copied=StringToCharArray(text, char_array); PrintFormat("String length: %u\nNumber of characters copied (with terminal 0): %d\nArray of characters for the string '%s':", StringLen(text), copied, text); //--- 在日志中记录结果数组 ArrayPrint(char_array, 0, " | "); /* result: String length: 50 Number of characters copied (with terminal 0): 51 Array of characters for the string 'This is a test of the StringToCharArray() function': [ 0] 84 | 104 | 105 | 115 | 32 | 105 | 115 | 32 | 97 | 32 | 116 | 101 | 115 | 116 | 32 | 111 | 102 [17] 32 | 116 | 104 | 101 | 32 | 83 | 116 | 114 | 105 | 110 | 103 | 84 | 111 | 67 | 104 | 97 | 114 [34] 65 | 114 | 114 | 97 | 121 | 40 | 41 | 32 | 102 | 117 | 110 | 99 | 116 | 105 | 111 | 110 | 0 */ } |