⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 whole_system.c.bak

📁 图书管理系统  给予文件的 可以运行的  在MINGW上运行
💻 BAK
字号:
/* file_name:	whole_system.c
 * author:	wangtiezhen miuliang @ Xidian University
 * description:	
 */
typedef enum {bb, book, stu} _enum_type;
int super_destory(void** root, _enum_type type)
{
	extern int bb_destory(bbpointer);
	extern int book_destory(bookpointer);
	extern int stu_destory(stupointer);
	
	switch(type){
		case bb:
			bb_destory(*root);
			break;
		case book:
			book_destory(*root);
			break;
		case stu:
			stu_destory(*root);
			break;
		default:
			break;	
	}
	*root = NULL;
}


int write_bb(struct bb* root, FILE *fp){
//	putchar('j');
        if(root == NULL) {
                return -1;
        }
        
        write_bb (root->lchild, fp );
        fprintf(fp, "%d\t%d\n", root->bnum, root->snum);
        write_bb (root->rchild, fp );
        
        return 1;
}
int write_stu(struct stu* root, FILE *fp){
//	putchar('j');
        if(root == NULL) {
                return -1;
        }
        
        write_stu (root->lchild, fp );
        fprintf(fp, "%s\t%d\t%d\t%d\t%s\n", root->name, 
        	root->num, root->password, root->age, 
        	root->addr);
        write_stu (root->rchild, fp );
        
        return 1;
}
int write_book(struct book* root, FILE *fp){
//	putchar('j');
        if(root == NULL) {
                return -1;
        }
        
        write_book (root->lchild, fp );
        fprintf(fp, "%d\t%s\t%s\t%d\n", root->bnum, root->bname,
               root->bwriter, root->bprice);
        write_book (root->rchild, fp );
        
        return 1;
}
int super_write(void)
{
	FILE *fp;
	if( (fp = fopen("book", "w") ) == NULL) {
                printf("It cann't write book to file\n");
                return -1;
                /* Cannot open the file */
        }
        write_book(bookbt, fp);
        if( (fp = fopen("student", "w") ) == NULL) {
                printf("It cann't write stu to file\n");
                return -1;
                /* Cannot open the file */
        }
        write_stu(stubt, fp);
        if( (fp = fopen("bb", "w") ) == NULL) {
                printf("It cann't write bb to file\n");
                return -1;
                /* Cannot open the file */
        }
        write_bb(bbbt, fp);
        return 0;
}



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -