The first one is probably trying to write to NULL, since it's a global.
You got lucky in the second one. In that one it might not be NULL, and might point to somewhere in a valid memory page.

Main must return int, not void.