void findStu (BST_TREE* list) { // Local Definitions char name[30]; STUDENT* stuPtr; // Statements printf("Enter student's name: "); scanf ("%s", name); stuPtr = (STUDENT*)BST_Retrieve (list, name); if (stuPtr){ printf("Student name: %s\n", name); printf("Student phone: %s\n", stuPtr->phone); } // if else printf("Student %s not in file\n", name); } // findStu
/* ===== readFile ===== This function inputs the data from the file Pre hash, list, cars Post nothing */ void readFile(HASH *hash, D_LIST *list, BST_TREE *cars){ CAR car; FILE *fp; CAR *fill; D_NODE *pPre = list->tail; char input[250]; fp = fopen("Cars.txt","r"); if(!fp){ printf("Error. Cannot Read File"); exit(100); } while((fgets(input,sizeof(input), fp))){ car = stringToCar(input); insert(hash,car); insertDNode(list, car); pPre = pPre->back; if(!BST_Retrieve(cars, &car)) { fill = (CAR*)malloc(sizeof(CAR)); if(!fill) { printf("Memory FULL\n"), exit(101); } fill->name = allocateString(car.name); fill->brand = allocateString(car.brand); fill->cost = car.cost; strcpy(fill->plate, car.plate); BST_Insert(cars, fill); cars->count++; } } }// readFile