frankfurt_schoolgirl [she/her]@hexbear.nettoProgramming@programming.dev•How do I handle an input thats more than the char size in c?English
1·
1 year agoDidn’t know about that one, thanks!
Didn’t know about that one, thanks!
If you want to accept a user input of any length, you have to read the input piece by piece and allocate a new buffer if the original becomes full. Basic steps would be:
malloc
to make a char *
buffer\0
to your buffer and break the loop. You’re done!memcpy
to copy the stuff from the old buffer to the new one. Use free
to get rid of the old buffer.This will work until you fill the entire memory of your computer. You should probably set a max length and print an error if it is reached.
The point of the post is to introduce you to async Rust libraries, not to prove that Rust is the best language for web dev.
But actually I’m afraid most of your comment is incorrect because the best language for web development is sml.
Is the Singleton accessed by one thread or many?
If it’s one thread, couldn’t you just wrap the
Vec
in anRc
and then clone your singleton every time you need it in a new scope?If it’s many, you should use channels and a dedicated logging thread imo.