gpt4 book ai didi

c++ - 在 C++ 和 Mysql 中,从 std::sqlString 到 char const* 的转换无效

转载 作者:行者123 更新时间:2023-11-28 06:47:15 25 4
gpt4 key购买 nike

con->setSchema(DATABASE);
// Query section
stmt = con->createStatement();
res = stmt->executeQuery("SELECT * FROM `submission` WHERE 'status' = 0");
while (res->next()) {
// Access column data by alias or column name
string insert = res->getString('pid');
const char* p = insert.c_str();

pipe = fopen(p, 'w');

fprintf(pipe,"Successfully created");
}

如何将 res->getString('pid') 值转换为 fopen() 作为文件名。我得到错误,因为它要求 char const*

最佳答案

con->setSchema(DATABASE);
// Query section
stmt = con->createStatement();
res = stmt->executeQuery("SELECT * FROM `submission` WHERE 'status' = 0");
while (res->next()) {
// Access column data by alias or column name

string insert = res->getString('pid'); //changed 'pid' to "pid"

const char* p = insert.c_str();

FILE *pipe = fopen(p, 'w'); // Declared pipe as FILE

fprintf(pipe,"Successfully created");
}

关于c++ - 在 C++ 和 Mysql 中,从 std::sqlString 到 char const* 的转换无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24741991/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com