#include <stdio.h>

/* Terry Harvey CISC105 Section 21 TA Aaron*/

/* Sample struct program for class */

struct student{
    int id;
    char name[30];
    double gpa;
};
void changeStructStudentArray(struct student data[]);
void printStudent(struct student temp);

int main(){

    struct student s1;
    struct student s2 = {2341, "worf", 9.5};
    struct student udel[13000];
    s1.id = 1234;
    s1.gpa = 3.99;
    strcpy(s1.name, "spam");

    printStudent(s1);

    printStudent(udel[0]);//should have garbage
    changeStructStudentArray(udel); //changes a struct by using array address
    printStudent(udel[0]);//should have id of 127

    s2 = s1;

    /* s2.name = s1.name ??? NO, cannot assign arrays */
    return 0;
}

/* This function takes a struct student as parameter. Structs are
   pass-by-value, and so this function cannot affect the original
   struct student in main. */
void printStudent(struct student temp){
    printf("%s  %d  %lf\n", temp.name, temp.id, temp.gpa);
    return;
}

/* This function takes an array as parameter. It is specified as an
   array of struct students. Because it gets the address of the
   original array in the calling function, this function can change
   the contents of the array. Note that this function is for
   demonstration purposes only. */
void changeStructStudentArray(struct student data[]){
    data[0].id = 127;
    return;
}
