Array of pointers structure type

There is no error while compiling but there is a run time error anyone knows why?

#include<iostream>
using namespace std;
struct StrCar{
char RegCode[10];
int PhoneNo;
char Colour[10];
int Model;
};
int main(){
StrCar *Car[1]={0}; //declaring array of pointers

cout<<"enter1:"<<endl;

cin.getline(Car[0]->RegCode,10);

cout<<"you entered"<<endl;

cout<<Car[0]->RegCode<<endl;

system("pause");
return 0;
}
Last edited on
Currently Car[0] points to memory location 0. This location is not accessible from your program, so you get a runtime error. What you need to do is make it point to some StrCar object. see http://www.cplusplus.com/doc/tutorial/pointers/ and http://www.cplusplus.com/doc/tutorial/dynamic/
Topic archived. No new replies allowed.