1.按逗号换行。
#include<fstream> #include<iostream> #include<string> using namespace std; int main() { string s; ifstream ci("wa.txt"); ofstream co("wb.txt",ios::app); while(ci>>s) { //co.put(ci.get()); co<<s; if(s[s.size()-1]==',') co<<endl; } ci.close(); co.close(); return 0; }