3 ms·
Why is open() in fcntl.h and close() in unistd.h? Why does bcopy go src,dst I don't know about the rest, but open(), close() and bcopy() are not in the C stand
by quietbritishjim 8y ago
Why is open() in fcntl.h and close() in unistd.h? Why does bcopy go src,dst
I don't know about the rest, but open(), close() and bcopy() are not in the C standard library. They are either POSIX or Linux specific. The C standard library functions for files start with f e.g. fopen(), fclose().
On a tangential topic, I don't know of a good reference for exploring what is included in the standard library.
The classic book The C Programming Language covers most, if not all, of the standard library. The whole thing can be found in an appendix. Admittedly reading an appendix isn't normally the best way to learn about something, but the library is so small and the amount not already covered in the text is even smaller so it wouldn't take long to skim. Of course it doesn't cover Unix-specific functions, like the unistd.h header; for that, I recommend Advanced Programming in the Unix Environment.
- tonysdg 8y agoI'd add that The C Programming Language should be seen as a tutorial (albeit an older one that no longer is fully up-to-date in best practices, in my experience) that can serve as a reference in a pinch (it skimps a bit on the corner cases if memory serves). Advanced Programming in the Unix Environment, conversely, should be seen as a reference book with fantastic examples and discussion on error handling -- yes, you can use it as a tutorial, but it's a tad dense and you'll likely never need a lot of it.
- loeg 8y agoNone of these are Linux specific :-). All were in POSIX; bcopy was deprecated in the 2004 iteration and removed in 2008.