having errors with a program, an office equipment inventory

am working on a program, an office equipment inventory but i have errors, this is the program below.

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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
  #include <iostream>
#include <iomanip>


using namespace std;

class Inventory{
    public:
        string type;
        int equip;
        string mode;
        int date;
        string location;
        string status;
        void getdata();
        void showdata();
};

void Inventory :: getdata(){
    cout<<"\n Enter equipment type: ";
    cin>>type;
    cout<<"Enter equipment no: ";
    cin>>equip;
    cout<<"Enter mode aquired : ";
    cin>>mode;
    cout<<"Enter date purchased or donated: ";
    cin>>date;
    cout<<"Enter office location: ";
    cin>>location;
    cout<<"Enter status: ";
    cin>>status;
}

void Inventory :: showdata(){
    cout<<endl;
    cout.width(10);
    cout.setf(ios::left, ios::adjustfield);
    cout<<type;

    cout.width(10);
    cout.setf(ios::left, ios::adjustfield);
    cout<<equip;

    cout.width(10);
    cout.setf(ios::left, ios::adjustfield);
    cout<<mode;

    cout.width(10);
    cout.setf(ios::left, ios::adjustfield);
    cout<<date;

    cout.width(10);
    cout.setf(ios::left, ios::adjustfield);
    cout<<location;

    cout.width(15);
     cout.setf(ios::right, ios::adjustfield);
    cout<<status;
}

int main(){
    int i;
    int n;
    Inventory record;

    cout<<"\n              OFFICE EQUIPMENT INVENTORY\n";
    cout<<"\nHow many Records do you want to create : ";
    cin>>n;

    cout<<"\nEnter details of "<<n<<" Records\n";
    for(i=0;i<n;i++)
     record.getdata();

    cout<<"\n\n\t STOCK INFORMATION"<<endl;
     cout<<"        -------------------\n\n";
        cout<<"Type      Equip no   Mode      Date     Office loc     Status"<<endl;
    cout<<"-------------------------------------------------------------------------------";

    for(i=0;i<n;i++)
        record.showdata();
        cout<<"\n\n\n\n\n\n\n";
    return 0;
}

You need to include #include <string>
thanks for that, but still not working the problem is that the output is suppose to be the list of the inputted values but the program carries the last value and replace it for the rest
What are this errors?

One thing: You need an array of recorde e.g.

Inventory record[100]; // The index (i) must not exceed 99

otherwise you will see only the very last record data.


Alternatively you better have a vector of record:

http://www.cplusplus.com/reference/vector/vector/
thanks let me try it
Topic archived. No new replies allowed.