I'm making a network program/game and I want to prevent clients from ........ing up the buffers.
char buf[x] has a limit... is there a way to make x dependent on user input? (strlen or something).
I'm making a network program/game and I want to prevent clients from ........ing up the buffers.
char buf[x] has a limit... is there a way to make x dependent on user input? (strlen or something).
Read everything into a fixed-length buffer initially. All the good input functions allow you to specify a buffer and a length.
When you've got the buffer and its actual length, then allocate whatever memory you need to store that (linked list, array, whatever) and copy from your input buffer to you allocated memory.
Rinse and repeat until you have all the input you need.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.