Computer Science 2574
Intro to Data Structures & Soft Eng

/*---------------------------------------------------------------------
-Module Name:             odbwrite.c
-Interface File:          odbwrite.h
-Implementation File:     odbwrite.c
-Description:
-this file is responsible for writing all of the information
-either to the disk or displaying it on the screen.
-
-Functions:	Name			Purpose
-
-		WriteODBFile		writes an odb file from existing data
-
-
-
-
-Called by:     odb.c
-
-Author:      	Jon Ford
-Revision:	3/27/96
-Version:     	1.1
-----------------------------------------------------------------------*/
#include
#include
#include


#include"odbwrite.h"


/*-----------------------------------------------------------
-Funciton Name:      WriteODBFile
-Description:
-this function writes the header and individual student
-information to the file specified by the user.
-
-Description of Algorithm:
- Writes the header and then loops through the linked
-list writing each record until it reaches the end.
-
-
-
-Called by:          odb.c
-Parameters:         ListMgr - pointer to head of list
-
-Author:      Jon Ford  
-Revision:
-Version:     1.0
--------------------------------------------------------------*/
void WriteODBFile(ListMgr listmgr)

{
	
	FILE* odbptr;
	ElemPtr current;

		

	current=ReturnFirst(listmgr);

	if ((odbptr=fopen(listmgr->title.opfilename,"w"))==NULL)
	{
		/*can't open the file - do nothing*/
	}
	else
	{
		fprintf(odbptr,"%-80s\n", listmgr->title.desc);
		fprintf(odbptr,"DATE %-11s\n",listmgr->title.date);
		fprintf(odbptr,"STUDENTS %-5dQUESTIONS %-5d\n",
		listmgr->title.students,listmgr->title.questions);
		while(current!=NULL)
		{
			fprintf(odbptr,
			"%-11s%-17s%-2s%-4s%-6d%-5d%-3s%-3s%-2s%-4.0f%-4.0f\n",
			current->item.SSN, current->item.lastname,
			current->item.initial1,current->item.initial2, 
			current->item.correctcount,
			current->item.omittedcount, current->item.seatnumber, 
			current->item.form,current->item.group, 
			current->item.score, current->item.tscore);
			current=ReturnNext(current);
		}
		fclose(odbptr);

	}

}