c++依次读取文件 到指定字符
例如件text.txt中有这么一段话:I,LOVE,YOU,BABY
如何一次一次读到指定的 ‘,’ 然后换行
输出:
I
LOVE
YOU
BADY
#include <fstream>
#include <string>
#include <iostream>
using namespace std;
int main()
{
char data[100];//
ifstream f;
string read;
f.open("C:\\Users\\hasee\\Desktop\\tmp.json");
while(getline(f,read,','))
{
cout<<read<<endl;
}
return 0;
}