AIIQ2 - return 0; } void read(istream& in,...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
#include <iostream> #include <fstream> #include <string> using namespace std; struct employee { string first; string last; int id; float salary; }; void read(istream& in, employee& x); void write(ostream& out, const employee& x); struct workforce { int size; employee* database; }; void read(istream& in, workforce& w); void write(ostream& out, const workforce& w); void updatesalary(workforce& w, int ident, float newsalary); int main(void){ workforce w; ifstream fin("workforcee.in"); ofstream fout("workforce.out"); int ident; float newsalary; read(fin, w); cout << "Enter the id and the new salary: "; cin >> ident >> newsalary; updatesalary(w, ident, newsalary); write(fout, w); system("notepad workforce.out");
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: return 0; } void read(istream& in, employee& x){ in>>x.first>>x.last>>x.id>>x.salary; } void write(ostream& out,const employee& x) { out<<x.first<<endl<<x.last<<endl<<x.id<<endl<<x.salary<<endl; } void read(istream& in, workforce& w){ int i; in>>w.size; w.database=new employee[w.size]; for(i=0;i<w.size;i++) read(in,w.database[i]); } void write(ostream& out,const workforce& w){ int i; out<<w.size<<endl; for(i=0;i<w.size;i++) write(out,w.database[i]); } void updatesalary(workforce& w, int ident, float newsalary){ int i(0); while(1){ if(w.database[i].id==ident){ w.database[i].id=ident; w.database[i].salary=newsalary; break; } i++; } }...
View Full Document

This note was uploaded on 02/21/2010 for the course ENGM 2282 taught by Professor Phillips during the Winter '10 term at Dalhousie.

Page1 / 2

AIIQ2 - return 0; } void read(istream& in,...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online