原文:https://zhidao.baidu.com/question/1819941753548219028.html
#include <fstream>
#include<iostream>
using namespace std;
int main()
{
ofstream oFile;
//打开要输出的文件
oFile.open("scoresheet.csv", ios::out | ios::trunc);
oFile << "姓名" << "," << "年龄" << "," << "班级" << "," << "班主任" << endl;
oFile << "张三" << "," << "22" << "," << "1" << "," << "JIM" << endl;
oFile << "李四" << "," << "23" << "," << "3" << "," << "TOM" << endl;
oFile.close();
}
注意:这里的”,“就相当于EXCEL表格的每一列,不能省略。