3 int report(x_HDDM_t *tscript);
10 x_Enrolleds_t* enrolleds;
18 fp = init_x_HDDM(
"exam2.hddm");
19 for (i=0;i<1000000;i++) {
22 tscript = make_x_HDDM();
23 tscript->student = student = make_x_Student();
24 student->enrolleds = enrolleds = make_x_Enrolleds(99);
26 enrolleds->in[0].courses = courses = make_x_Courses(99);
28 courses->in[0].result = make_x_Result();
29 courses->in[1].result = make_x_Result();
30 courses->in[2].result = make_x_Result();
33 name = (
char*)malloc(30);
34 strcpy(name,
"Humphrey Gaston");
36 enrolleds->in[0].year = 2005;
37 enrolleds->in[0].semester = 2;
38 courses->in[0].credits = 3;
39 course = (
char*)malloc(30);
40 courses->in[0].title = strcpy(course,
"Beginning Russian");
41 grade = (
char*)malloc(5);
42 courses->in[0].result->grade = strcpy(grade,
"A-");
43 courses->in[0].result->Pass = 1;
44 courses->in[1].credits = 1;
45 course = (
char*)malloc(30);
46 courses->in[1].title = strcpy(course,
"Bohemian Poetry");
47 grade = (
char*)malloc(5);
48 courses->in[1].result->grade = strcpy(grade,
"C");
49 courses->in[1].result->Pass = 1;
50 courses->in[2].credits = 4;
51 course = (
char*)malloc(30);
52 courses->in[2].title = strcpy(course,
"Developmental Psychology");
53 grade = (
char*)malloc(5);
54 courses->in[2].result->grade = strcpy(grade,
"B+");
55 courses->in[2].result->Pass = 1;
58 flush_x_HDDM(tscript,fp);
63 fp = open_x_HDDM(
"exam2.hddm");
65 while ((tscript = read_x_HDDM(fp)) != 0) {
66 if (count/100000*100000 == count) {
67 printf(
"event %d\n", count);
72 printf(
"finished after %d events read.\n", count);
78 x_Student_t* student = tscript->student;
79 x_Enrolleds_t* enrolleds = student->enrolleds;
80 x_Courses_t* courses = enrolleds->in[0].courses;
81 int total_courses = courses->mult;
82 int total_enrolled = 0;
83 int total_credits = 0;
86 for (i=0;i<total_courses;++i) {
87 if (courses->in[i].result->Pass) {
88 if (enrolleds->in[0].year > 1992) {
89 total_credits += courses->in[i].credits;
94 printf(
"%s enrolled in %d courses and passed %d of them,\n",
95 student->name, total_courses, total_passed);
96 printf(
"earning a total of %d credits.\n", total_credits);
printf("string=%s", string)
int main(int argc, char *argv[])
int report(x_HDDM_t *tscript)