What do you mean by this? At the end it points to '\0'...
I take that back, I was overthinking.
I was thinking about local variables being lost i.e. "going out of scope" when a function ends.
This doesn't hold for this case, you're returning a mere address.
And I just want to ask about free(). Does it basically set the next malloc pointer to "overwrite" what it was pointing to? Im not really sure what free does...
I think it simply unmarks the memory as being in use.
As for your program you should manage your string outside the getinput() function. Because once you free() it, I personally wouldn't trust its contents anymore but maybe that's just me.
As a matter of interest... I tried avoiding the string terminator '\0' and it doesn't affect the programme. What difference does it make in this scenario?
Chances are the memory you're allocating is "clean" meaning it's 0000000000 when you allocate it...
Putting a '\0' will make a difference when the memory happens not to be "clean".