-
Notifications
You must be signed in to change notification settings - Fork 0
/
products.cpp
68 lines (65 loc) · 1.88 KB
/
products.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include<iostream>
#include<string>
#include<stdlib.h>
#include<string.h>
#include<fstream>
#include<cstring>
using namespace std;
class items
{
char itemname[25];
float itemid;
float itemprice;
float itemrating;
public:void read()
{
items it;
ofstream fp1;
ifstream
fp.open("itemfeed.dat");
for(int i=0;i<5;i++)
{
cout<<"DETAILS:"<<endl;
cout<<"ID:";
cin>>it.itemid;
cin.ignore();
cout<<"NAME:";
cin>>it.itemname;
cout<<"PRICE:";
cin>>it.itemprice;
cout<<"RATING:";
cin>>it.itemrating;
fp.write((char*)&it,sizeof(it));
}
fp.close();
}
void display()
{
fstream fp;
fp.open("itemfeed.dat");
items it;
fp.read((char*)&it,sizeof(it));
while(!fp.eof())
{
cout<<"*********************************************************"<<endl;
cout<<"ID:";
cout<<it.itemid<<endl;
cout<<"NAME:";
cout<<it.itemname<<endl;
cout<<"PRICE:";
cout<<it.itemprice<<endl;
cout<<"RATING:";
cout<<it.itemrating<<endl;
cout<<"*********************************************************"<<endl;
fp.read((char*)&it,sizeof(it));
}
fp.close();
}
};
int main()
{
items i1;
i1.read();
i1.display();
return(0);
}