3 ms·
Casting to and from void is a "lesser known" feature of C?
by EPWN3D 3y ago
Casting to and from void is a "lesser known" feature of C?
- wruza 3y agoAlso “lesser known” means “not in C FAQ” to me. Half or more of TFA is a pretty regular C FAQ material that everyone C already has read. I mean, sure, right?
- defrost 3y agoPretty much. Although even things in the C FAQ get overlooked and forgotten. eg: a 'Day of the Week' one liner such as dow = (y + y/4 - y/100 + y/400 + m["-bed=pen+mad."] + d) % 7; with int day (d), month (m), year (y) inputs and single int day of week output has a slight twist that causes a few head scratches for some.
- zalyalov 3y agoThat... that way to handle leap years can't possibly be right, can it? It doesn't account that you don't need to add the leap day of the current year if the day is before Feb 29
- defrost 3y agoErr, my bad, I left out the prequel (still a one liner) y -= m < 3; dow = as above, etc; I was focused on an 'obscure' yet fundemental part of the C language pointer | array equivalence. Addendum: https://c-faq.com/misc/zeller.html https://c-faq.com/misc/zeller.html