0
으로 변환하는 방법 txt 파일을 구문 분석하고 싶습니다. excel 파일로 작성해야합니다. excel을위한 라이브러리 재미가 있습니다. const char * 파일을 구문 분석하고 데이터를 저장하고 전달하는 데 const char *를 사용합니다. 그 내 코드를 보여주는 벡터 재미의 제공 오류 배역 오류 :벡터를 const char *
#include<iostream>
#include<string>
#include<fstream>
#include<vector>
#include<sstream>
using namespace std;
vector< vector<string> > data;
void parse(const char* name)
{
ifstream in(name);
string line;
// read the file
while (getline(in,line,'|'))
{
vector<string> fields;
std::stringstream linestream(line);
for (int col = 0 ; col < 21 ; col++)
{
string f;
linestream >> f;
fields.push_back(f);
}
data.push_back(fields);
}
// output by rows
for (vector< vector<string> >::size_type row = 0 ; row < data.size() ; row++)
{
for (vector<string>::size_type col = 0 ; col < data[row].size() ; col++)
{
// std::vector<char> copy = data;
//char * buffer = ©[0];
/*char *buffer = new char[data.size()];
std::copy(data.begin(), data.end(), buffer);*/
//buffer=static_cast<char *>(data[row]);
//cout << buffer[row];
cout << data[row][col];
}
cout << endl;
}
// output by columns
/*for (vector<string>::size_type col = 0 ; col < data[0].size() ; col++)
{
for (vector< vector<string> >::size_type row = 0 ; row < data.size() ; row++)
{
cout << data[row][col] << ",";
}
cout << endl;
}*/
}
static void example1(const char* path)
{
sheet->Cell(row, col)->Set(data[r][c]);/i need to pass vector into this fun
}
enter code here
고맙습니다. – suneetha
@suneetha 제 대답이 당신이 문제를 해결하는 데 도움이된다면, 제 대답을 받아들이는 것이 너무 친절 할 수 있습니다. 이것은 귀하의 질문을 해결 된 것으로 보여주고 약간의 신용을줍니다. 감사. –