reserve()
描述
String 物件的 reserve() 函式可以配置一块记忆体空间来存放字串。
语法
string.reserve(size)
参数
string : String 物件 (字串)
size : 要配置的记忆体大小 (用来存放字串) unsigned int 型别
回传
无回传值
范例
String myString;
void setup() {
// 初始化 Serial 并等待序列埠打开:
Serial.begin(9600);
while (!Serial) {
; // 等待序列埠打开。
}
myString.reserve(26);
myString = "i=";
myString += "1234";
myString += ", is that ok?";
// 印出字串:
Serial.println(myString);
}
void loop() {
// 这里不做任何事
}
See also
- String
The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.
