Please bear with me, i m from other language and newbie to c and learning it from http://c.learncodethehardway.org/book/learn-c-the-hard-way.html
struct Person {
The function returns who
, which is a struct Person *
- a pointer to a structure. The memory to hold the structure is allocated by malloc()
, and the function returns a pointer to that memory.
If the function were declared to return struct Person
and not a pointer, then who
could also be declared as a structure. Upon return, the structure would be copied and returned to the caller. Note that the copy is less efficient than simply returning a pointer to the memory.