I have made a function for receiving data on a socket connection. Now what I want is that function returns the received data. The data could be anything so that's the reason why I chose for a char.
But this code only returns one character and that is logical because buffer is declared as a char instead of a char*, but by doing that I get a runtime error. Any solutions how to solve this?
Your variable named "buffer" is the stack area.When your program run out this function,the stack area will be destroyed.
You can use a global array for "buffer".
e.g:
For some C complier,there are no inline.You have to define global scope to transfer data.
Especially in embeded system.almost 80% of them use the standard C or cutted C.
How to solve this bug depend the situation.All rules may have to change for special situation.