草庐IT

CharacterVector

全部标签

c++ - 将 Rcpp::CharacterVector 转换为 std::string

我正在尝试在Rcpp中打开一个文件函数,所以我需要文件名作为char*或std::string。到目前为止,我已经尝试了以下方法:#include#include#include#includeRcppExportSEXPreadData(SEXPf1){Rcpp::CharacterVectorff(f1);std::stringfname=Rcpp::as(ff);std::ifstreamfi;fi.open(fname.c_str(),std::ios::in);std::stringline;fi>>line;Rcpp::CharacterVectorrline=Rcpp::