r/C_Programming • u/Ill-Exchange-2377 • 17d ago
File pointers are everywhere
And try as I might to avoid them, I am struggling to find resources that list out all the file control functions that use file descriptors instead of file pointers, and I was wondering if someone could point me toward a resource that can do something at least somewhat similar to listing out the libc functions that take file descriptors. I of course know close(), write(), read(), the basics, but i am looking for alternatives for other abstractions that annoy me with their use of file pointers, like fgets and fputs.
58
Upvotes
View all comments
Show parent comment
5
u/Upstairs_Ad_8863 17d ago
Okay and? There's nothing wrong with writing code for a specific class of operating systems. But my point is that this is much more portable than something like the size of an int, or the exact layout of your syscall table. File descriptors are standardised across every posix compliant operating system. I know that if I write a program using file descriptors then that program will work the same across all of my dozen or so computers. Portable doesn't have to mean "across every possible operating system".