#include <iostream>
using namespace std;
struct node
{
int data;
node *next;
};
int main()
{
node *n, *t, *h;
n = new node;
n->data = 1;
t = n;
h = n;
n = new node;
n->data = 2;
t->next = n;
t = n;
n = new node;
n->data = 3;
t->next = n;
t = n;
n = new node;
n->data = nullptr;
n = h;
while(n != nullptr)
{
cout << n->data << endl; // EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
n = n->next;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgogIHVzaW5nIG5hbWVzcGFjZSBzdGQ7CgogIHN0cnVjdCBub2RlCiAgIHsKCWludCBkYXRhOwoJbm9kZSAqbmV4dDsgCiAgIH07CgogaW50IG1haW4oKQogewoJbm9kZSAqbiwgKnQsICpoOwoJCgluID0gbmV3IG5vZGU7CgluLT5kYXRhID0gMTsKCXQgPSBuOwoJaCA9IG47CgkKCW4gPSBuZXcgbm9kZTsKCW4tPmRhdGEgPSAyOwoJdC0+bmV4dCA9IG47Cgl0ID0gbjsKCQoJbiA9IG5ldyBub2RlOwoJbi0+ZGF0YSA9IDM7Cgl0LT5uZXh0ID0gbjsKCXQgPSBuOwoJCgluID0gbmV3IG5vZGU7CgluLT5kYXRhID0gbnVsbHB0cjsKCQoJCiAgICBuID0gaDsKICAgIHdoaWxlKG4gIT0gbnVsbHB0cikKICAgICAgewoJIGNvdXQgPDwgbi0+ZGF0YSA8PCBlbmRsOyAgLy8gRVhDX0JBRF9BQ0NFU1MgKGNvZGU9RVhDX0kzODZfR1BGTFQpCgkgbiA9IG4tPm5leHQ7CiAgICAgICB9CgkKCgkKCXJldHVybiAwOwogfQ==