#include%26lt;stdio.h%26gt;
#include%26lt;conio.h%26gt;
#include%26lt;string.h%26gt;
int choice,height_of_arrays=8;
struct textbook{
char title[40];
char firstname[20];
char surname[20];
char isbn[14];
}books[20];
/*void writefile()
{
int ic;
FILE*f;
f=fopen("books.dat","wb");
for(ic=0;ic%26lt;height_of_arrays;ic++);
fwrite(%26amp;books[ic],sizeof(struct textbook),1,f);
fclose(f);
}
void readfile()
{ int ic;
FILE *f;
ic=-1;
if((f = fopen("books.dat","rb"))== NULL)
{
printf("\nbooks.dat file not found ");
getch();
ic=0;
}
else
{
do
{
ic= ic+1;
fread(%26amp;books[ic],sizeof(struct textbook),1,f);
}while(!feof(f));
fclose(f);
}
}
*/
void setup()
{ strcpy(books[0].firstname,"John");
strcpy(books[0].surname,"Phillips");
strcpy(books[0].title,"barcode recorgnition");
strcpy(books[0].isbn,"0-01-0445-125")...
strcpy(books[1].firstname,"Thomas");
strcpy(books[1].surname,"Jones");
strcpy(books[1].title,"barcode recorgnition");
strcpy(books[1].isbn,"0-02-4825-126")...
strcpy(books[2].firstname,"Wright");
strcpy(books[2].surname,"Morgan");
strcpy(books[2].title,"barcode recorgnition");
strcpy(books[2].isbn,"0-03-2075-127")...
strcpy(books[3].firstname,"John");
strcpy(books[3].surname,"Stockman");
strcpy(books[3].title,"barcode recorgnition");
strcpy(books[3].isbn,"0-04-4403-128")...
strcpy(books[4].firstname,"Sunday");
strcpy(books[4].surname,"Allison");
strcpy(books[4].title,"barcode recorgnition");
strcpy(books[4].isbn,"0-05-0539-129")...
strcpy(books[5].firstname,"Raffel");
strcpy(books[5].surname,"Banites");
strcpy(books[5].title,"barcode recorgnition");
strcpy(books[5].isbn,"0-06-3310-121")...
strcpy(books[6].firstname,"Shawn");
strcpy(books[6].surname,"Cole");
strcpy(books[6].title,"barcode recorgnition");
strcpy(books[6].isbn,"0-07-1445-122")...
strcpy(books[7].firstname,"Alan");
strcpy(books[7].surname,"Campbell");
strcpy(books[7].title,"barcode recorgnition");
strcpy(books[7].isbn,"0-08-0115-123")...
height_of_arrays=9;
}
void add_new_textbook()
{
char temp_isbn[14];
int ic,found_book=0;
do
{
printf("\n Please Enter Valid ISBN Code for the textbook to be added!!");
gets(temp_isbn);
} while (strlen(temp_isbn)!=13);
for(ic=0;ic%26lt;height_of_arrays;ic++)
{
if(strcmpi(temp_isbn,books[ic].isbn)==0)
{
printf("ISBN already exist on the database!!");
found_book=1;
getch();
}
}
if(found_book==0)
{
// printf("You have entered a Correct ISBN");
// scanf("%s",%26amp;temp_isbn);
clrscr();
printf("\n Please enter Firstname of textbook author");
scanf("%s",%26amp;books[ic].firstname);
clrscr();
printf("\n Please enter surname of textbook author");
scanf("%s",%26amp;books[ic].surname);
clrscr();
printf("\n Please enter the title of textbook");
scanf("%s",%26amp;books[ic].title);
}
}
//int choice;
/*void add_new_textbook()
{
printf("\n Well done, add a new textbook called successfully!");
getch();
}*/
void search_records()
{
clrscr(); int ic;
for(ic=0;ic%26lt;8;ic++);
{
printf("\n%s\title\firstname\surname\i...
printf("\n Well done, Search records called successfuly!");
getch();
}
}
void display_all_textbooks()
{
clrscr(); int ic;
for(ic=0;ic%26lt;8;ic++);
{
printf("\n%s\title\firstname\surname\i...
printf("\n Well done, Display all textbook called successfully!");
getch();
}
}
void quit()
{
printf("\n Bye for Now, Quit called successfully!");
getch();
}
void menu_choice()
{
do
{
clrscr();
printf("Welcome to R%26amp;D Department EPOS Options Ltd");
printf("\n");
printf("\n1. Add a New Textbook");
printf("\n");
printf("\n2. Search Records by ISBN");
printf("\n");
printf("\n3. Display all Textbooks");
printf("\n");
printf("\n4. Quit\n");
printf("\n");
printf("\nPlease Enter Choice-%26gt;");
choice=getch();
switch(choice)
{
case '1': add_new_textbook();
break;
case '2': search_records();
break;
case '3': display_all_textbooks();
break;
case '4': quit();
break;
default:puts("Invalid menu choice, please enter 1-4 as a menu choice");
getch();
break;
}
}
while (choice!='4');
}
void main()
{
clrscr();
setup();
//readfile();
menu_choice();
add_new_textbook();
search_records();
quit();
display_all_textbooks();
//writefile();
}
Can any c++ wizard check d codes posted and make it compile and run also make the 4 menu options works?
Yes, contact a freelancer to fix this issue from websites like http://getafreelnacer.com/
Reply:Ask in IRC. ##c++ on Freenode. They will help you, but not spoon feed you.
No one will just fix your code for you. You need to learn the answer.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment