Article Index

Function to save a record to the file.

#include "project.h"

void WriteRec(COURSE* CoursePointer)
{
	FILE* record;                                            //Declare file pointer

	record = fopen("Record.txt", "wt");                      //Open file
	fprintf(record, "%s\n", CoursePointer -> number);
	fprintf(record, "%s\n", CoursePointer -> title);
	fprintf(record, "%d\n", CoursePointer -> credit);
	fprintf(record, "%d\n", CoursePointer -> lab);

	fclose(record);                                          //Close file

	return;
}
Log in to comment