Re:The C23 edition of Modern C is now available for free
by unwind on Wednesday October 16, 2024 @03:54AM
(#41856642)
No actual C programmer who has been around the block more than halfway should do that. The mantra is: "read into a character buffer, then parse that".
It's more code, sure, but it buys you a lot of good things. I/O is hard.
Re:The C23 edition of Modern C is now available for free
by PaulDavisThe1st on Wednesday October 16, 2024 @09:37AM
(#41858912)
No C++ programmer who has been around the block more than halfway should do
cin >> a;
and assume that it works.But also ...
sscanf (the_buffer, "%d", &a);
doesn't help the problem in any substantive way.
in both cases, you need error checking (which you "know about").