CCDataVisitor.h, #include <string> 'string' file not found

2 篇文章 0 订阅
1 篇文章 0 订阅

CCDataVisitor.h, #include <string> 
'string' file not found

 

这个错误因为你的.m文件引用里.mm的文件,这里需要把.m改成.mm就可以了。

#include <Windows.h> #include <iostream> #include <fstream> #include <string> #include <vector> #include <algorithm> #include <cstdlib> #include <ctime> #include <conio.h> #include <winsock.h> #include <ws2bth.h> #include <bluetoothapis.h> #pragma comment(lib, "ws2_32.lib") using namespace std; const string CONFIG_FILE = "config.ini"; const int MAX_BLUETOOTH_DEVICES = 10; int main() { // 读取配置文件 ifstream config(CONFIG_FILE); if (!config.is_open()) { cout << "无法打开配置文件!" << endl; return -1; } string line; int search_count = 0; while (getline(config, line)) { if (line.find("search_count") != string::npos) { search_count = stoi(line.substr(line.find("=") + 1)); break; } } config.close(); // 初始化蓝牙 WSAData wsaData; int iResult = WSAStartup(MAKEWORD(2, 2), &wsaData); if (iResult != NO_ERROR) { cout << "WSAStartup 失败!" << endl; return -1; } // 枚举蓝牙设备 BLUETOOTH_DEVICE_SEARCH_PARAMS searchParams = { sizeof(BLUETOOTH_DEVICE_SEARCH_PARAMS) }; searchParams.fReturnAuthenticated = TRUE; searchParams.fReturnRemembered = TRUE; searchParams.fReturnUnknown = TRUE; searchParams.hRadio = NULL; BLUETOOTH_DEVICE_INFO deviceInfo = { sizeof(BLUETOOTH_DEVICE_INFO) }; HBLUETOOTH_DEVICE_FIND deviceFindHandle; vector<BLUETOOTH_DEVICE_INFO> devices; deviceFindHandle = BluetoothFindFirstDevice(&searchParams, &deviceInfo); if (deviceFindHandle != NULL) { do { devices.push_back(deviceInfo); } while (BluetoothFindNextDevice(deviceFindHandle, &deviceInfo)); BluetoothFindDeviceClose(deviceFindHandle); } // 检查蓝牙设备数量 if (devices.size() >= MAX_BLUETOOTH_DEVICES) { ofstream file("CheckBT.log"); file << "PASS"; // 向文档中写入"PASS"字符串 } else { ofstream file("CheckBT.log"); file << "FAIL"; // 向文档中写入"FAIL"字符串 } // 清理蓝牙 WSACleanup(); return 0; }改进这段代码,在生成文档中输出搜索到的蓝牙设备名称
05-15
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值