String.reserve()

名称

String.reserve()

説明

Stringオブジェクトを操作するためのバッファを確保する。

書式

unsigned char String::reserve(unsigned int size);

引数

sizeStringオブジェクトを操作するために必要なメモリ量。

戻り値

なし。

使用例

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
String myString;

void setup() {
  // initialize serial and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB
  }

  myString.reserve(26);
  myString = "i=";
  myString += "1234";
  myString += ", is that ok?";

  // print the String:
  Serial.println(myString);
}

void loop() {
  // nothing to do here
}

参照

利用例 String Tutorials

オリジナルのページ

https://www.arduino.cc/reference/en/language/variables/data-types/string/functions/reserve/

Last Revision: 2019/02/19

最終更新日

January 4, 2024

inserted by FC2 system