what is wrong for one line it works for array it doesnt

#include<iostream>
#include<fstream>
#include<string>

using namespace std;
const int max = 100;
int main()
{
fstream inputfile("inventory.txt");
string make[max];
string modle[max];
int number[max];
int qty[max];
double price[max];
string partname;
int i = 0;
for (; !inputfile.eof();i++)
{
inputfile >> make[i] >> modle[i] >> number[i] >> qty[i] >> price[i];
cout << make[i] << "\t" << modle[i] << "\t" << number[i] << "\t" << qty[i] << "\t" << price[i] << "\t" << partname[i] << endl;
}
return 0;
you need a different variable for each array.
just make a structure to define your array.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
struct car
{
string make;
string model;
int number;
}


int main()
{
int i;
car aCar[SIZE];

for(i = 0; i < SIZE; i++)
{
cout << "Enter make: "  << endl;
cin >> aCar[i].make;
}


I just did the basic model of my idea and how to store the data.

also max can't be an array of a string and an int.
Topic archived. No new replies allowed.