⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 信息录入.cpp

📁 学生通讯录系统
💻 CPP
字号:
#include<iostream>
#include<fstream>
#include"学生信息定义.h"
using namespace std;
void student::luru()
{
	
//	int stu_num;
//	cout<<"请输入要录入的学生个数:"<<endl;
//	cin>>stu_num;


	ofstream outfile("student.txt",ios::app);
	if(!outfile)
	{
		cerr<<"open error:"<<endl;
		exit(1);
	}
	
	cout<<"请输入下列学生信息:"<<endl;
	cout<<"姓名   学号   年龄   性别   家庭住址   电话   寝室号"<<endl;
	cout<<"姓名"<<endl;
	cin>>name;
	cout<<"学号"<<endl;
	cin>>number;
	cout<<"年龄"<<endl;
	cin>>age;
	cout<<"性别"<<endl;
	cin>>sex;
	cout<<"家庭住址"<<endl;
	cin>>addr;
	cout<<"电话"<<endl;
	cin>>phone;
	cout<<"寝室号"<<endl;
	cin>>room_num;
	outfile<<name
		<<" "<<number
		<<" "<<age
		<<" "<<sex
		<<" "<<addr
		<<" "<<phone
		<<" "<<room_num;
	outfile.close();
	cout<<"信息已成功输入!"<<endl;
		ifstream infile("studentnum.txt",ios::out);
	if(!infile)
	{
		cerr<<"open error1:"<<endl;
		exit(1);  
	}
	infile>>stu_num;
    infile.close();
	stu_num++;
	ofstream outfile1("studentnum.txt",ios::out);
	if(!outfile1)
	{
		cerr<<"open error2:"<<endl;
	    exit(1);
	}
	outfile1<<stu_num;
	outfile1.close();
	cout<<""<<endl;
	cout<<""<<endl;
	cout<<""<<endl;
	
	
}



⌨️ 快捷键说明

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