写入excel
写入excel的代码,做个备份:
//#include"stdafx.h" #include <cstdio> #include<iostream> #include<cstring> //以下是文件读入输出需要的头文件 #include<fstream> #include<cstdlib> #include<streambuf> #include <string> using namespace std; const int maxn = 30; int i, j; struct node { long number; char name; int score; int sum; }; void write_to_excel(bool& flag, node& pp) { ofstream opt; opt.open("C++输出文档最新版.csv", ios::out|ios::trunc); opt << "学号" << "," << "姓名" << "," << "A科成绩" << ","<<"int" << endl; for (i = 0; i < maxn; i++) opt << pp.number << "," << pp.name << "," << pp.score << "," <<pp.sum << endl; opt.close(); flag = 1; } int main() { node pp; pp.name = '3'; pp.number = 45; pp.score = 23; pp.sum = 90; bool flag; write_to_excel(flag, pp);//写进表的函数 return 0; } /* #include<iostream> #include<vector> using namespace std; struct Mach { string a="a1"; }; struct BellMach :public Mach { string a="a2"; string b = "b2"; }; bool allocate(Mach mach){ cout << mach.a<<"a" << endl; return true; }; bool allocate(BellMach mach) { cout << mach.a <<"b"<< endl; return true; }; int main() { vector<Mach*> mv; Mach *mac1 = new Mach; mv.push_back(mac1); BellMach*bmac = new BellMach; mv.push_back(bmac); Mach* bmac1 = mv[1]; cout << bmac1->a << "a" << endl; BellMach* bmac2 = static_cast<BellMach *>(bmac1); cout << bmac2->a << "b" << endl; cout << bmac2->b << "b" << endl; return 0; } */
浙公网安备 33010602011771号