The C Book (HTML Book on C)
phy.duke.edu
phy.duke.edu
Unfortunately, most books simply vanish and/or have an unclear legal status.
# implied int; implied void
main() {
# whatever
exit(0) # or EXIT_SUCCESS
}
Is this simply a stylistic choice (rather than a more explicit int main(void) and return(0)). I'm mostly curious, but I know that how to deal with main can be a sacred cow.Edit: And sure enough clang (by default) and gcc (with -Wall) both issue warnings.
(And there's also a PDF of all the pages, linked to from the gbdirect version, http://publications.gbdirect.co.uk/c_book/the_c_book.pdf ; for those of you having trouble with the printer-friendly version.)
main(){
/* ... */
}
This is considered bad code style for todays standards. It doesn't state the return value (it defaults to int) and it leaves the argument list open (you can pass any number of arguments to the function).In other places, it puts restrictions that are no longer relevant today. For example, since C99 (and most compilers allowed this long before C99) you can declare variables anywhere inside a block (which is pretty handy), and not just at the beginning of the function.
I say it a lot too, especially when talking about interfacing with external resources, and I don't think it's anything to do with enjoying others' misery. It's simply being happy to have it confirmed that the problem you're observing is (probably) someone else's fault, not your own; this carries the bad news that you (probably) can't fix it yourself, but the good news that you don't have to fix it yourself.