Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我char在 Arduino 草图中有以下内容:
char
char inData[80];
当我打印到串行控制台时:
Serial.print(strlen(inData) - 1);
我期待看到:79而我看到:655356553501234567
有人可以解释为什么会这样吗?
strlen正在寻找终止的 nul。在未初始化的数组或指针上调用它会导致未定义的行为。你想要sizeof(inData)。
strlen
sizeof(inData)