从Cocos2dx的指针char向量写入sqlite文件
Write to sqlite file from vector of char of pointer in Cocos2dx
我正在使用HttpClient类。当我得到响应时,我想要将响应数据写入文件。当我检查文件时,它的格式错误,不能作为正常的sqlite文件打开。我的代码有什么问题?
// Get data
std::string path = cocos2d::FileUtils::getInstance()->getWritablePath()
+ "test.db3";
auto buffer = response->getResponseData();
FILE *pFile;
pFile = fopen(path.c_str(), "wb");
int size = buffer->size();
fwrite(&size, sizeof(int), 1, pFile);
fclose(pFile);
OP.
// Get data
std::string path = cocos2d::FileUtils::getInstance()->getWritablePath()
+ "serverdb.sqlite";
auto buffer = response->getResponseData();
std::ofstream ofs;
ofs.open(path.c_str(), std::ios::out | std::ios::trunc);
ofs.write(&(buffer->front()), buffer->size());
ofs.flush();
ofs.close();
相关文章:
- QT QML:使用.qrc文件将SQLite数据库部署到Android不起作用
- 如何将SQLite c文件(合并)与cpp应用程序链接?
- 如何确定 SQLite 文件在 QML LocalStorage 中的存储位置
- 在这种情况下,将数据存储在诸如SQLite之类的数据库中,还是存储在平面文本文件中更好
- C++SQLite在C接口中导入整个CSV文件
- SQLite是否可以完成此任务?存储路径名与文件属性
- 无法执行 sqlite SQL 文件来创建数据库
- C++和 Sqlite DELETE 查询实际上不会从数据库文件中删除该值
- SQLite 通过 C++ 打开多个 SQLite 文件
- QSql数据库并连接到 .sqlite 文件
- 将 MySQL 表存储到文件 (sqlite?)
- SQLite:在 WAL 模式下持久化文件句柄
- 使用 Visual Studio 编译 SQLite C++ 2013 抛出 .c 文件的错误
- C++:关闭后不能删除 sqlite 文件
- 设置SQLite数据库文件的版本
- Sqlite将数据库保存/加载到文件流中
- 其中是存储在ODBC++示例中的sqlite数据库文件
- SQLite,iCloud,也许还有Core Data——用于存储文件并与所有用户的设备共享?
- Android NDK不能交叉编译SQLite - crtend_so.0:没有这样的文件或目录
- 从Cocos2dx的指针char向量写入sqlite文件