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.