Since it is not initialized with valid address and you are accessing that address to modify the value, the segmentation fault occurs! Just allocate some valid address and try... it should work.