Lab05 C
Lab05 C
Lab05 C
c
// Lab05.c : Defines the entry point for the console application.
#include "studentrecord.h"
#include "myfunctions.h"
int main(void)
{
//
PrintName();
//lab02
//
DealCards();
//
DiceGame();
//lab03
//
PrintRange();
//lab04
//
TestArrayFn();
//lab05
StudentInformation();
//Pause();
return;
}
studentrecord.c
#include<stdio.h>
#include "studentrecord.h"
void StudentInformation(void)
{
char choice;
int status=0;
int SID=0;
int SRecord[MAXRECS] = {0};
printf("Student Information\n");
while (1)
{
printf("\nEnter 'R' to Register a Student\n");
printf("Enter 'D' to De-Register a Student\n");
printf("Enter 'S' to Display Student Information\n");
printf("Enter 'C' to Display Class Information\n");
printf("Enter 'Q' to Quit\n");
scanf(" %c", &choice);
switch(choice)
{
case 'r':
case 'R':
status = RegisterStudent(GetStudentID(),SRecord);
if (status == 2)
{
printf("\nID is already Registered\n");
}
else if (status == 1)
{
printf("\nRecord Added\n");
}
else if (status == 0)
{
printf("\nOut of Record Space\n");
}
break;
case 'd':
case 'D':
status = DeregisterStudent(GetStudentID(), SRecord);
break;
case 's':
case 'S':
status = DisplayStudentInformation(GetStudentID(), SRecord);
break;
case 'c':
case 'C':
DisplayClassInformation(SRecord);
break;
case 'q':
case 'Q':
return;
default:
printf("\nInvalid Menu Selection ...\n");
}
}
}
int RegisterStudent(int SID, int SRecord[MAXRECS])
{
int i = 0;
}
for (i = 0; i< MAXRECS; i++)
{
if (SRecord[i] == 0 )
{
SRecord[i] = SID;
return 1 ;
}
}
return 0;
int i = 0;
for (i = 0; i< MAXRECS; i++)
{
if ( SID == SRecord[i])
{
printf("\nStudent Information\nStudent ID\n\n%d\n", SID );
return 1;
}
}
return 0;
}
void DisplayClassInformation(int SRecord[MAXRECS])
{
int i = 0;
{
int SN;
while (1)
{
printf("\nEnter a 5 Digit Student Number: ");
scanf("%d", &SN);
studentrecord.h
#ifndef STUDENTRECORD_H
#define STUDENTRECORD_H
#define MAXRECS 10
//function prototypes
void StudentInformation(void);
#endif
makefile
lab05: lab05.o myfunctions.o studentrecord.o
gcc -g -o lab05 lab05.o myfunctions.o studentrecord.o -lm
lab05.o: lab05.c myfunctions.h studentrecord.h
gcc -g -c lab05.c
myfunctions.o: myfunctions.c myfunctions.h
gcc -g -c myfunctions.c
studentrecord.o: studentrecord.c studentrecord.h
gcc -g -c studentrecord.c