ofstream outfile("d:\\data\\f1.txt", ios::out);//对象与文件的关联,并指定工作模式, 默认 if (!outfile) { cerr << "open file error!" << endl; abort(); } outfile << p.name< outfile.close();