VSC++中变量的问题?

DDSMJB DDSMJB 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
各位大神,楼主小白,想请教一个问题,有个程序打印出的数据是printf("#%d -> %.6f, %.6f, %.6f, %.6f\n", dev_index, qx, qy, qz, qw) 我想把第一位的%d变成我接收传感器的dev.address。源程序部分如下:
#include <string>
#include <vector>
#include <list>
#include <iterator>
#include <iostream>
#include <functional>

#include "libSuyunBleInvoker.h"
#include "SUYUN_WBLE_Callback.h"

libSuyunBleInvoker invoker;

std::vector<BTDevice> scaned_devices;

int connect_index = 0;

void OnScanResult( std::list<BTDevice>* devices ) {
// clear out of date devices infomation
scaned_devices.clear();

// save devices infomation
std::copy( devices->begin(), devices->end(), std::back_inserter( scaned_devices ) );

// print device infomation
if( scaned_devices.size() > 0 ) {
printf( "Scan Result:\n" );

for( auto & dev : scaned_devices ) {
printf( "Device: %s, %s, %ddBm\n", dev.name, dev.address, dev.rssi );
}

// connect sensor one by one, when connected or not, it calls OnEvent function
invoker.connect_device( connect_index, scaned_devices[ connect_index ].address );
} else {
printf( "No device found.\n" );
}
}

// print quaternion components received from ble sensor
void OnData( const int dev_index, float qx, float qy, float qz, float qw, const int sr, const int bp ) {
printf( "#%s -> %.6f, %.6f, %.6f, %.6f\n", dev.address, qx, qy, qz, qw );
}

这个我手动改成了printff( "#%s -> %.6f, %.6f, %.6f, %.6f\n", dev.address, qx, qy, qz, qw ),不过报错dev.address未定义。。
...全文

相关推荐

评论 10
收藏 已收藏
分享
返回顶部
DDSMJB
VC/MFC 16,550 成员 421,606 内容