I am working on this project and i am going to need to write information and retrieve them from a file. I get all the information needed but i am not sure how to write it to a file and how to get it back.
if (id.is_open())
{
cout<<endl;
cout<<"Enter type: "<<endl;
cin>>type;
a.settype(type);
cout<<"Enter description: "<<endl;
cin>>description;
a.setdescription(description);
cout<<"Enter Counter: "<<endl;
cin>>counter;
a.setcounter(counter);
cout<<"Enter Priority: "<<endl;
cin>>priority;
a.setpriority(priority);
//a.display();
b.addInode(a.getincidentid(), a.gettype(), a.getdescription(), a.getcounter(), a.getpriority());
a.setincidentid(a.getincidentid()+1);
}
I want to put this information in a file. I am using the linklist which is the addInode. How do i get it into a file and retriveing it from a file. I did some reasearch and i think fstream would do the job. Any help or suggestions would be appreciated.
I should add that i have a file but i am not sure how to get the node in it. After the information is entered into the file i would like to read in back and print out the entire node back to the user.
void displayInode(int key) //displays the content of a specific node when searched for
{
incident *temp=head;
while(temp!=NULL)
{
if(temp->getincidentid()==key)
{
temp->display();
return;
}
temp=temp->getNextincident();
}
cout<<"this client record does not exist"<<endl;
}
bool isfull()
{
incident *cn;
cn=new incident;
if(cn==NULL)
return true;
else
{
delete cn;
return false;
}
}
This is the display note snippet i am going to use it after i pull the ID from the file then print it back to the user.