为什么论点接受" text"但不是字符串变量?

时间:2018-03-15 13:04:04

标签: c++ mbed bbc-microbit

我正在尝试将microbit上的加速度计的整数x y z组合成一个字符串,然后将其发送到串行端口。我在这里使用microbit DAL库在线mbed编译器中使用c ++。

container-fluid

但是result.c_str()给了我一个错误错误:Class" std :: basic_stringstream,std :: allocator>"没有会员" c_str" in" main.cpp",Line:26,Col:34 screenshot

1 个答案:

答案 0 :(得分:3)

这可能是因为方法send只接受const char*作为参数而不是std :: string。尝试:

uBit.serial.send(result.c_str());

编辑:

现在您的代码已更改,结果是字符串流:

uBit.serial.send(result.str().c_str())

相关问题