【发布时间】:2011-12-11 18:56:58
【问题描述】:
在 C++ 中(在 Arduino 上)可以实现这样的事情吗?
#include "stdio.h"
String str = "foo";
int i[strLength()]; // <- define length of array in function
int strLength() {
return str.length();
}
int main(void) {
...
}
提前谢谢你!
【问题讨论】:
-
您使用的是 C++ 还是 C? C 没有任何“字符串”对象。
-
其实我使用的是 Arduino,我认为它使用的是 C++。
-
String是什么类型?是std::string吗?您平台中的某些特定类型? -
String是一个 Arduino 字符串 (arduino.cc/en/Reference/StringObject)。 Arduino 不支持 STL 的任何部分。