...

View Full Version : help!!!with c++



flagstone
10-31-2007, 06:22 PM
i am trying tocreate a library management program using file i\o.i am stuck please help.this is what i have done.


//library
#include<iostream.h>
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<fstream.h>
class lib
{
public:
char name[120];
char genre[20];
char author[20];
int doi;
int dor;
void getdata();
void display();
};
void lib:: getdata()
{
cout<<"enter the books name";
cin>>name;
cout<<"emter author";
cin>>author;
cout<<"enter genre";
cin>>genre;

}
void lib:: display()
{
cout<<"book\tauthor";
cout<<endl<<name<<"\t"<<author<<"\t"<<genre;

}

void main()
{cout<<"MENU"<<endl;
cout<<"1."<<"enter a book"<<endl;
cout<<"2."<<"issue"<<endl;
int p;
fstream filout("q.txt",ios::app);
int n;
char c;
lib b[10];
cin>>p;
switch (p)
{ case 1:
{ int i=0,j;
cout<<"do u want to enter more books ?";
cin>>c;
while(c=='y'||c=='Y')
{
cout<<"enter the no of books";
cin>>n;
for(i;i<n;i++)
{ b[i].getdata();
b[i].display();
filout<<b[i].name<<"\t"<<b[i].author<<"\t"<<b[i].genre<<"\n";
cout<<endl<<endl;
}
cout<<"do u want to continue?";
cin>>c;
}
filout.close();

ifstream fin("q.txt");
fin.seekg(0);
cout<<"________\n\n";
// for(j=0;j<i;j++)
j=0;
do
{
fin>>b[j].name;
fin>>b[j].author;
fin>>b[j].genre;
cout.width(7);
cout<<j+1<<". "<<b[j].name<<"\t\t"<<b[j].author<<"\t\t"<<b[j].genre<<endl;
// fin>>author;
j++;
} while(fin);

fin.close();
break;
}
case 2 :
{ cout<<endl<<"to issue"<<endl;
char bok[20];
fstream is;
is.open("q.txt",ios::in|ios::out);
cout<<endl<<"enter the name of book u want to issue";
cin>>bok;
while(is)
{ int k=0;
if (bok ==b[k].name )
{
cout<<"enter date of issue";
cin>>b[k].doi;
cout<<"book is due on"<<b[k].doi+7;
}
k++;

}
break;
}
}
}

oracleguy
10-31-2007, 06:57 PM
Please read our guidelines on homework assignments (http://www.codingforums.com/showthread.php?t=53446).

What is wrong with your program? What do you need help with? You need to be more specific.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum