#include <iostream>
usingnamespace std;
int main () {
int x = 5;
int *a;
int *b;
*a = x;
b = &x;
cout << "a's address is " << a << endl;
cout << "b's address is " << b << endl;
cout << "a's value is " << *a << endl; // Segmentation fault here
cout << "b's value is " << *b << endl; // Segmentation fault here
return 0;
}
'a' is a pointer to an int, but is not initialized. When you dereference it in line 11, you assign the value of x (5 in this case) to some unknown location in memory.