Shiyu Wang Lec25 April 14th
Exam average is around 5-6
for text file
fscanf(filename,"%d",&val)
for binary file
fread(&val, sizeof(int), 1, filename)
===================
Kevin Tan(0023987592), section#2 notes 04/12
EXAM Q2 Thing thing_construct(int w,char *l) {
Thing t; t.label = strdup(1); t.weight = w; return t;
}
Thing Thing_copy(Thing p) {
return thing_construct(P.weight,P.label)
}
void Thing_merge(Thing *dst,Thing src) {
char *l; dst->weight = src.weight; char *l1 = dst->label; char *l2= src.label; l= malloc(sizeof(char)*(strlen(l1)+strlen(l2)+1)); strcpy(l,l1); strcpy(l,l2); free(dat->label); dst->label = 1;
}
void Thing_destory(Thing p) {
free(p.label);
}
void Thing_print(Thing p) {
printf("weight = %d, label = %s\n",p.weight,p.label);
}