All pastes #1342476 Raw Edit

employeedb.cpp

public cpp v1 · immutable
#1342476 ·published 2009-02-20 02:19 UTC
rendered paste body
#include <iostream>#include <fstream>#include <string>/*********** employeedb.cpp - Pass two database files to this program and it will display a nice formatted list* sorted by name, employee number, and salary.**********/using namespace std;struct employeeDetails {	string name,employeeID,salary;};employeeDetails employees[500];struct task {	int taskID;	string taskName;	int employeeID[10]; // Only 10 people can work on any one task.};void usageHelp(char progName[]) {	cout << "Usage:" << endl << progName << " [employee database file] [task database file]" << endl;	exit(0);}int readEmployeeDatabase(char file[]) {	int i;	fstream f (file,fstream::in);	for(i=0;f.ios::eof() == 0;i++) {		getline(f,employees[i].name,',');		//cout << employees[i].name << end; // debug		getline(f,employees[i].employeeID,',');		getline(f,employees[i].salary);		cout << employees[i].name << endl << employees[i].employeeID << endl << employees[i].salary << endl; // debug	}	f.close();	return i;}void readTaskDatabase(char file[]) {	int taskCount;	task tasks[500];	fstream f (file,fstream::in);	f.close();}void bubbleSort(char *array,int length) // Using the bubble sort method. {	int i,j;	for(i=0;i<=length;i++) {		for(j=0;j<i;j++) {			if(array[i]>array[j]) {			int temp=array[i]; 			array[i]=array[j];			array[j]=temp;			}		}	}}int main(int argc, char *argv[]) {	const int employeeCount=readEmployeeDatabase(argv[1]);	int i;	if (argc == 1) {		usageHelp(argv[0]);	}	employeeDetails employees[employeeCount];	cout << "---" << endl << "Employee Name     Employee ID     Salary" << endl << "---" << endl;		for (i=0;i<=employeeCount;i++) {		cout << employees[i].name << " " << employees[i].employeeID << " " << employees[i].salary << " " << endl;	}	return 0;}