Where can you find the important information you need to know before
starting the assignment?
Structs
What is a struct?
How does it differ from an array?
How could we represent a student and their assignment 1 mark as a struct?
What fields might we want to include?
Create a struct student with the name "Frankie",
zid of 5151515, assignment 1 mark of 60.2 in the main function (hint, you do
not need functions or malloc).
Struct Pointers
Use a function to create a struct student *
with the name "Chicken", zid of 5252525, assignment 1 mark
of 71 using a function (hint, you will need to use malloc)
Which of these structs is currently causing a memory leak and why?
Use dcc --leakcheck to confirm this.
We have a struct student and a struct student *:
If we want to access the fields of these, when do we use . and
when do we use ->?
Edit the existing struct student, to be able to point to
another struct student.
Update your function which creates an instance of a student to account
for this new pointer.
Build a linked list to represent a class of students by adding new
students at the head of the list.
Create another struct definition and instance to represent the class.
It should contain the name (i.e. M13A), the number of students and a
pointer to the linked list you just made.
Revision questions
The remaining tutorial questions are primarily intended for revision - either this week or later in session.
Your tutor may still choose to cover some of the questions time permitting.
Give a struct that might hold lab, assignmment and exam marks for a COMP1511 student.
Remember, there is more than 1 lab and more than 1 assignment.
What is wrong with this program? Fix these issues in the file below.
#include<stdio.h>#define MAX_PLATE 10000structparking_fine{doubleamount;charnumber_plate[MAX_PLATE];};intread_parking_fine(structparking_fine*fine);intmain(void){structparking_finef;if(read_parking_fine(f)){printf("%lf %s\n",f.amount,f.number_plate);}return0;}// return 1 if a parking fine was successfully read, 0 otherwiseintread_parking_fine(structparking_fine*fine){if(scanf("%lf",(fine.amount))!=1){return0;}returnfgets(fine->number_plate,MAX_PLATE,stdin)!=NULL;}