You can only do declarations in the global scope. So a function call can't execute in the global scope. As malloc() is also a function call, it couldn't execute.
So you can declare the global pointer variable and initialize it any all other functions (not restricted to main only). Since the pointer is global it is available globally after initialization at any of the functions.
Asked in February 2016Viewed 3,157 timesVoted 7Answered 2 times