为什么我无法调用字符串向量的元素来代替字符串?

到目前为止,这是我代码的一部分,我正在尝试将csv文件解析为2D向量并创建地图

#include "csvreader.h"
#include <map>
#include <iomanip>
#include <fstream>
#include <sstream>


extern std::vector<std::string> str;
extern std::vector<int> idx;

csvreader::csvreader(std::string file_name)
{
    this->file_name = file_name;
} 

std::vector<std::vector<std::string>> csvreader::read_csv(std::map<std::string,std::map<std::string,int> >& freq_table)
{
std::string file_name = " ";
std::vector<std::vector<std::string> > csv_data;
std::vector<std::string> tuple;
std::ifstream csvfile(file_name);
int row = 0;
int col = 0;
std::string line;
std::vector<std::string> data;
while (csvfile)
{
    std::getline(csvfile,line);
    std::string newline;
    newline = line + "\n";
    data.push_back(newline);
}
col = count(data.at(0).begin(),data.at(0).end(),',') + 1;
row = data.size() - 1;
csvfile.close();
std::ifstream csvfile(file_name);

std::string temp;
for (int j = 0; j < col; j++)
{
    std::getline(csvfile,temp,');
    str.push_back(temp);
    freq_table[str(j)] = std::map<std::string,int>();
    idx.push_back(j);
}

我的问题出现在这部分

std::string temp;
for (int j = 0; j < col; j++)
{
    std::getline(csvfile,int>();
    idx.push_back(j);
}

我可以调用freq_table [temp],但是当我将字符串插入字符串向量中时却无法执行。

ilyu1314 回答:为什么我无法调用字符串向量的元素来代替字符串?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3127568.html

大家都在问