3 ms·
I don't think I've ever seen ungetc() used in production code. I appreciate the "do it yourself" thing - but in 2023 unless you're building a product for a kno
by notbeuller 3y ago
I don't think I've ever seen ungetc() used in production code.
I appreciate the "do it yourself" thing - but in 2023 unless you're building a product for a known ascii system, you're setting yourself up for pain when your code is run in San José,
- NikkiA 3y ago> I don't think I've ever seen ungetc() used in production code. I have, I wish I hadn't, but there we go. I'd rank it up there with f77 return labels as being coding clusterfucks.
- dfox 3y agoungetc() exists for exactly this application. But when you want more abstract input stream than FILE* you have to reimplement that yourself on higher layer. Ironically even libc implementation needs an more generic abstraction to implement scanf() and sscanf() (ie. you either have two separate implementations of these or don't internally use ungetc())