什么是最好的方式摆脱,我相信他们是所谓的"回车"(在文件的末尾,它会自动创建一个新行),在一个文件中?我从文件中读取,解析和标记化数据,但它被搞砸了回车。
编辑::我其实只是通过文件读取程序,并创建一个整数,对应线的总数,然后刚刚与修改后的版本的整数循环。
--------------------------------------
试图把这两码在一起,但不确定如何:
守则一:
第二个代码:
// reading a text file
#include<iostream>
#include<fstream>
#include<string>
#include<algorithm>
using namespace std;
int main () {
string teststr, teststr1;
string stop;
ifstream incsv ("example.csv");
ofstream outtxt ("examplet.txt");
if (incsv.is_open())
{
int x=0;
while (x<5)
{
getline(incsv, stop, '\n');
x=(x + 1);
}
while (!incsv.eof())
{
getline(incsv, teststr, '\"');
replace(teststr.begin(), teststr.end(), ',', '|');
getline(incsv, teststr1, '\n');
replace(teststr1.begin(), teststr1.end(), '\"', ',');
outtxt << teststr << teststr1 << endl;
}
incsv.close();
return 0;
}
}
{C}