问题是我有这个文件,但我不知道如何在没有引号或逗号的情况下获取字符串或数字,并将其放在辅助变量中,
"string one" , 2500:25670, (0.676,-2.43)
"string two",259: 8765 , ( 12.22 , -7.56 )
目前我写了这段代码:
string filename = getFilename(); //function to get filename
string line;
string data;
ifstream file;
file.open(filename.c_str(),ios::in);
if (!file.is_open())
{
error(ERR_CANT_OPEN_FILE);
}
else
{
while(getline(file,line))
{
bases.push_back(tempBases));
}
}
答案 0 :(得分:0)
在逐行读取文件的循环中:
while(getline(file,line))
{
// parse line to a token of strings with comma delimiter and assign each token to variables or put to the vector
}