what is wrong with the following simple code?

int *n;
 int a=1; n=&a; 
 cout <<"n="<<*n<<"\n";

It compiles, but print out "Bus Error".

I am compling this code under Mac OS X, Unix shell, g++.

Nothing is wrong with that code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.