Im trying to learn c++ loops and structures with the c++ primer plus book.
My current code:
#include <iostream>
#include <string>
struct car
{
std::string carname;
int yearmade;
};
int main(void)
{
using namespace std;
int zero = 0;
int vb2 = 1;
int count2;
int zero2 = 0;
int count = 0;
int strcture;
cout << "How many cars do you wish to catalog? ";
cin>>strcture;
car * cars[strcture] = new car;
while(count != strcture)
{
cout <<"Car# " << vb2;
cout <<"Please enter the make: ";
getline(cin, cars[zero]->carname);
cin.get();
cout <<" Please enter the year made: ";
cin.get();
cin >> cars[zero]->yearmade;
cin.get();
count++;
vb2++;
zero++;
}
cout <<"Here is your collection:\n";
while(count2 =! strcture)
{
cout<< cars[zero2]->yearmade << cars[zero2]->carname;
zero++;
}
return 0;
}
im stuck on the part on the while loops, my compiler just keeps telling me: variable-sized object `cars' may not be initialized|
plz help.
thanks.