int main ()
cout<<"Enter the number of cars";
cin >> ncar;
data *f= new data[ncar];
cout<<"Observation "<<i+1<<": \n";
cout<<"Enter with car"<<": \n";
cout<<"Enter with the brand"<<": \n";
data *f=&f[ncar]; // I think the problem is here because I cant using arrays with pointers...
(*f).car = newCar;
cout<<"Enter with correct car"<<": \n";
Put the code you need help with here.
Are you trying to create a new data with data *f=&f[ncar];?
A data * type is the same as data type when changing its values.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
int * i = newint;
cout<<i<<" "<< j<<endl; // this prints 5 two times
delete  i; //don't forget to free memory
First, you do introduce a pointer variable with name "f". However, you already have a pointer variable with name "f". Your compiler should say something about that.
Second. f[ncar] dereferences the pointer. It is equivalent to *(f+ncar). However, f points to a memory block that has only ncar data elements. You do dereference memory one past your array. If you want your new pointer to point to the beginning of the array, you can use f directly.