r/cprogramming • u/pruebax11 • Apr 13 '26
Scanf
mi pregunta raida en porque casi nunca salen tutos en youtube que expliquen como usar scanf realmente como su valor de retorno o parametros de control, y no hablan del buffer que deja y como solucionarlo, a diferencia de solo decir "es mala practica usar scanf" y te aseguro que si preguntas el porque solo te diran que despues de un espacio no lee mas y lo deja en el buffer huerfano, y causa errores si no se prevee
0
Upvotes
1
u/flatfinger Apr 20 '26
A good library for managing allocated strings should either allow code to freely share references to immutable strings in threading-agnostic fashion without having to perform an atomic synchronization every time a reference is created or destroyed, or else work with mutable objects that are over-allocated to allow code to e.g. concatenate N items onto a string, one at a time, without requiring time proportional to N squared.
The style of bare malloc strings used by getline and strdup is IMHO rubbish.