int main(){
	FILE *fp;
	fp = fopen("phones.txt", "r+");
	
	char name[30];
	char phone[20];

	BST_TREE* list;
	list = BST_Create (compareStu);

	// while(!feof(fp)){...}
	while(fscanf(fp, "%s %s", name, phone) == 2){
		// printf("%s, %s\n", name, phone);
		addStu(list, name, phone);
	};
	fclose(fp);

	char option = ' ';
	while ( (option = getOption ()) != 'Q'){
	    switch (option){
	        case 'A': 
	        		  printf("Input name: ");
	        		  scanf("%s", name);
	        		  printf("Input phone: ");
	        		  scanf("%s", phone);
	        		  addStu (list, name, phone);
	                  break;
	        case 'D': deleteStu (list);
	                  break;
	        case 'F': findStu (list);
	                  break;
	        case 'P': printList (list);
	                  break;
	      } // switch 
	   } // while 

	fp = fopen("phones.txt", "w");
	BST_Traverse (list, saveStu);
	fclose(fp);

	list = BST_Destroy (list);

	printf("\nEnd Student List\n");
	return 0;
}
Esempio n. 2
0
int main(){
	HASH *hash;
	D_LIST *list;
	int size = 30;
	int i = 0;
	BST_TREE *tree = BST_Create(cmpID);
	list = createDoublyList();
	hash = createHashTable(size);
	readFile(hash, list, tree);
	process(hash, list, tree);
	
	
	hash = freeData(hash);
	freeLinkedList(list);
	tree = BST_Destroy(tree);
    
	printf("\n\t\tEnd of the program!\n" );
#ifdef _MSC_VER
    printf( _CrtDumpMemoryLeaks() ? "No Memory Leak\n" : "Memory Leak\n");
#endif
	getch();
    
}