【发布时间】:2014-06-10 19:14:12
【问题描述】:
所以我从 .csv 中读取,因为结果显示在图像 url 中。当我计算文件中的所有内容时,它会在每个读取的单元格之间打印额外的“”。所以我想知道为什么这些“”是cout-ed? 最重要的是有没有办法摆脱它们?
void Evidenca::IskanjeIstiVnos(vector<Evidenca>& evidenc, vector<Evidenca>& kopir, fstream &Datoteka){
string vrstica;
int StVrstic=0;
int Stej;
string TEMPsemester;
string TEMPletnik;
string TEMPects;
string TEMPocIzpita;
while(!Datoteka.eof()){
getline(Datoteka,vrstica,'\n');
Datoteka >> ws;
StVrstic++;
}
Datoteka.clear();
Datoteka.seekg(0, ios::beg);
cout << "Stevilo predmetov zapisanih v datoteki je: " << StVrstic<<endl; //How many lines are in file
for(int a=0;a<StVrstic;a++){
getline(Datoteka,ImePredmeta,';');
getline(Datoteka,ProfesorImPr,';');
getline(Datoteka,TEMPsemester,';');
getline(Datoteka,TEMPletnik,';');
getline(Datoteka,TEMPects,';');
getline(Datoteka,datumIzpita,';');
getline(Datoteka,TEMPocIzpita,'\n');
cout << ImePredmeta << " " << ProfesorImPr << " "<< TEMPsemester << " " << TEMPletnik << " " << TEMPects << " " << datumIzpita << " " << TEMPocIzpita << endl;
}
【问题讨论】:
-
因为它们在 .csv 文件中?
-
这些引号在你的文件中,用文本编辑器打开它。
-
while(!Datoteka.eof()){住手! -
为什么要投反对票?这个问题似乎有效。