short_record.cpp

来自「程序功能: 1 管理员开设课程; 2 学生可以选择课程; 3 学生注册; 」· C++ 代码 · 共 36 行

CPP
36
字号
#include "cpp9.h"
/********************
 * 生成简明文件函数
 ********************/
void  Student::short_record(Student *top)
{
	Student *p;
	p=top;
	if(p->count==0) 
	{
		cout<<"\t内存中没有可用记录"<<endl;
		return;
	}
	for(int i=0;i<p->count;i++,p=p->next)
	{
		strcpy(sm[i].name, p->name);
		sm[i].ave=p->ave;
	}
	ofstream out;
	out.open("stud_mean.dat",ios::out);
	if (!out)
	{
		cout << "\t不能打开文件!" << endl;
		return;
	} 
	cout << "\n\t存文件" << endl;
    out.write((char *)sm,sizeof sm);
	out.close();
	cout << top->count << "\t条记录已经存入文件,内容如下:" << endl;
	cout <<"\t名字\t平均成绩\n";
	for(i=0;i<p->count;i++)
		cout <<"\t"<<sm[i].name<<"\t"<<sm[i].ave<<endl;

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?