demoFile
demoFile
===============================
===============================
==============
// Name : DemoFileNhiPhan.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//
===============================
===============================
==============
#include <iostream>
#include<fstream>
#include<string>
using namespace std;
#define FNAME "SinhVien.txt"
struct SinhVien{
string hoTen;//char hoTen[25];
float dtb;
int tuoi;
//ham nhap, xuat thong tin
void nhapSVInfo(){
cout<<"Nhap ho ten: ";
getline(cin, hoTen);
cout<<"Nhap diem TB: ";
cin>>dtb;
cout<<"Nhap tuoi: ";
cin>>tuoi;
}
void hienSVInfo(){
cout<<"\nHo ten: "<<hoTen
<<"\nDTB: "<<dtb<<"\nTuoi:
"<<tuoi<<endl;
}
};
int main() {
/*
SinhVien sv;
cout<<"Nhap thong tin sinh vien: "<<endl;
sv.nhapSVInfo();
cout<<"Ghi thong tin sinh vien vao file:
"<<endl;
ghiFile(FNAME, sv);
*/
SinhVien dssv[10];
int slg;
cout<<"Doc du lieu sinh vien tu file: "<<endl;
docFile(FNAME, dssv, slg);
for(int i=0;i<slg;i++)
dssv[i].hienSVInfo();
return 0;
}