delete structure

i'm a newbie in this structure function, string functions, and i have this project of mine due on tuesday, march 17. Our professor wants us to have a book information system with add, delete display and exit . how can i display the information that will be input?? how can it be save? and after it is saved, how can someone delete it?? i already finish the add choice.. please, i need assistance with this.. thank you very much in advance for someone who can help me.. thank you thank you
Last edited on
What code do you have so far?
#include<iostream.h>
#include<conio.h>
#include<complex.h>
#include<process.h>
#include<stdio.h>
#include<string.h>
#include<dos.h>
int a,b,c;
char *ptr;

struct menu
{
char title[150];
char author[150];
int yr_pub;
int no_pg;
int acc_no;
}
s[1];
void main()
{
clrscr();
int opt;
cout<<" BOOK INFORMATION SYSTEM "<<endl;
cout<<endl<<">>>>> MENU<<<<< "<<endl;
cout<<endl<<"1. ADD"<<endl;
cout<<endl<<"2. DELETE"<<endl;
cout<<endl<<"3. DISPLAY"<<endl;
cout<<endl<<"4. EXIT"<<endl;
cout<<endl<<endl<<"OPTION:";
cin>>opt;

if(opt==1){
clrscr();
cout<<" ADD BOOK "<<endl;
cout<<"How many books you want to add?:";
cin>>a;

for(b=0; b<a;b++)
{
cout<<endl;
cout<<"TITLE OF THE BOOK:";
gets(s[a].title);
cout<<"AUTHOR:";
gets(s[a].author);
cout<<"YEAR BPUBLISH:";
cin>>s[a].yr_pub;
cout<<"NUMBER OF PAGES:";
cin>>s[a].no_pg;
cout<<"ACCOUNT NUMBER:";
cin>>s[a].acc_no;
}}
else if(opt==2)
{
cout<<"DELETE BOOK";
cout<<"TITLE OF THE BOOK YOU WANT TO DELETE:";
cin>>c;
ptr=strstr(c,c);



getch();
}


this are my codes so far..:]
Probably the first thing you should look at is the line that says:
s[1];
this doesn't do anything, if what you want is to create an array of something, you need to specify the type of info kept in the array, and a size,
like

int test_array[50];

will create an array of 50 ints;
Also you named your struct 'menu', which is very misleading, you should call it books or something like that.

Thirdly, kind of a style thing, you have variables declared all over the place, some in main, and some outside of any functions (global). Put them in the same place(in main).

Edit: also you are using the old c-style strings like char title[50]. this can cause alot of problems. What if the title is 60 characters? Since you have #included <string>, why not use
string title;
Then you can use the comparison operator(==) to check and see if two strings are equal. Clean it up a little and repost.

I just noticed that you are also using the old c style headers. Are you supposed to do this assignment in C or in C++?


Last edited on
i need to do this in turboc++...
thanks but i need more specific codes in deleting structures.. can you give some program that deleting the data with connection in my codes above?? pls?? any help would be appreciated.. thank you thank you
Last edited on
what i'm trying to ask is, after inputting some data at the add choice, it will be stored. (where will the data be stored?) then after that, for example, i want to display the data that are stored, it should get the data from what is stored from the add choice. and after that i want to delete an item there, after choosing delete, a new screen will appear then ask the title of the book that wants to be deleted. How will the program find that book? argh.. it's driving me crazy.. T.T pls.. thank you thank you
no reply?? pls help.. T.T
Topic archived. No new replies allowed.