gpt4 book ai didi

fopen - 没有匹配函数调用 'fopen'

转载 作者:行者123 更新时间:2023-12-02 21:10:56 30 4
gpt4 key购买 nike

我想在我的 cpp 函数中调用 fopen,但是,Rcpp 总是提示“没有匹配的函数来调用‘fopen’”。所以完全复制了 https://github.com/hadley/xml2/blob/9362d379e126a86091af8698a8987c51b5b230fe/src/xml2_doc.cpp 中的一些代码仍然有同样的错误。

#include <Rcpp.h>
using namespace Rcpp;

// [[Rcpp::export]]
void doc_write(std::string path){
FILE* f = fopen(path.c_str(), 'r');
fclose(f);
}

错误是:

testc.cpp:6:36: error: invalid conversion from 'char' to 'const char*' [-fpermissive]

有人可以给我一些提示吗?

最佳答案

错误消息告诉您需要知道的一切 - 您正在尝试传递一个 char 参数,其中需要一个 const char *
'r' 替换为 "r" 应该可以修复它。

关于fopen - 没有匹配函数调用 'fopen',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33491271/

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