Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
Help Me C Programmers
Old 05-22-2004, 09:19 AM Help Me C Programmers
Junior Talker

Posts: 3
Trades: 0
Objective: carry out a program that allow the management of the books in a library
Book information:
1. the book title(string)
2. the publish year(short)
3. the book code(string)
4. the author(string)
5. the editor(string)
6. the borrower(string)
7. the address of the borrower(string)
8. the state of the book(short) /*0 means available and 1 means the book is borrowed*/
9. the limit to return the borrowed book(date struct of day month and year)

Functions 1,2,3 are done the problem is in 4,5,6…10
Required:
1. Declare a structure type named BOOK ;
2. Declare a structure type named NODE to represent a node in an indexed tree. The indexed tree is a binary tree where each node is composed of two pointers (left and right), one string to represent the book code and an integer index of long type.
3. Write a function to open a new file that will contain the information concerning the books. The name of the file is the unique parameter of that function. The result will be a pointer to the file.
4. Write a function to create a file of books. The file is supposed opened in the right mode. The information concerning books will be entered via keyboard. The input will stop when the function detects an empty string of book title. The pointer to file is the only parameter of the function.
5. Recursive function to insert a string and an integer value (long type) in an indexed tree. The tree is sorted according to the string. The root of the tree, the string and the integer variables are the parameters of the function.
6. Function to read sequentially an existing and opened (in right mode) file of books and construct a sorted indexed tree. The information part in the node in the tree will contain the code of the book and the position of the book in the file. The tree will be sorted according to the codes of the books (string type) the pointer to the file of books is the only formal parameter of the function. This function will return the root of the constructed tree of indices.
7. Recursive function to determine using the code of a book the position of the book in the file by traversing the sorted index tree. The code of the book and the root of the tree of indices represent the parameters of the function. The function will return the position of the book in the file of books.
8. Function to modify the state of a book in the file of books if a borrower returned a book. The parameters are the root of the tree and the pointer to the file of books and the code of the book.
9. Function to modify the state of a book in the file of books if a borrower borrowed a book. The parameters are the root of the tree and the pointer to the file of books and the code of the book.

10. Function to print out the list of borrowed books in the library.

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
struct date{
int year;
int month;
int day;
}dt;

struct book{
char title[30]; /*the book title*/
char code[5]; /*the book code*/
char author[30]; /*the author name*/
char editor[30]; /*the editor name*/
short year; /*the publishing year*/
short state; /*0 or 1 means borrowed or available*/
char borrower[30]; /*the name of the borrower of the book*/
char bwr_adr[30]; /*the address of the borrower*/
struct date lmt_dt; /* the limit date to return the book*/
}bk;

struct node{
char bc; /*the book code in the node of a tree*/
long ind; /*the index of the book in the tree*/
node*right; /*the node right to this node*/
node*left; /*the node left to this node*/
}nd;

FILE* open_file_for_write(char* filename)
{
FILE* fw;
int cont=1;
do
{
fw=fopen(filename,"r");
if(fw==NULL)
{
fw=fopen(filename,"wb");
cont=0;
}
else
fclose(fw);
}
while(cont);
return
fw;
}
solo_han is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Reply     « Reply to Help Me C Programmers
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.08545 seconds with 12 queries