r/cprogramming • u/SubstantialCase3062 • Dec 31 '25
Input/Output in C
What u guys say are the important or useful input/output in c because there is so many to do the same job, like how do I also read man pages to see if a function is not safe or standard
9
Upvotes
2
u/SubstantialCase3062 Dec 31 '25
Yep thanks also I like to asked how do u get your information like links or any resources that can help me improve my skills and knowledge
2
u/TheOtherBorgCube Dec 31 '25
When reading manual pages, you'll typically see this to tell you which standard(s) the function conforms to.
4
u/dcpugalaxy Dec 31 '25
I assume you're trying to ask what the most useful input and output functions are in the C standard library.
There are two main modes of input/output: line-based text and binary. Most text formats are line-based.
For line-based text, input you should use
fgets. For output you should useprintf/fprintfandputs/fputs.For binary input and output you should use
freadandfwrite.I recommend you read this: https://sekrit.de/webdocs/c/beginners-guide-away-from-scanf.html
1
u/ffd9k Dec 31 '25
The best reference is the standard itself: https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3220.pdf
The input/output functions are in section 7.23.
(ignore Annex K)
1
u/penguin359 Jan 01 '26
There are two main standards if you are trying for portability. There's the ANSI C Standard library and there's POSIX. In general, the ANSI C library will be the most portable, but it is also a little higher level and won't include many things like shared memory. This includes functions from headers like assert.h, errno.h, stdlib.h, stdio.h, string.h, etc. This will often have a specific standard version like C89 or C11 associated with them and will be available on Windows, POSIX, or many other C environments following the standard library.
For things beyond what the standard library has, there's POSIX which can be used on Linux, BSD, and some of it even on Windows to a degree. On Windows, it can depend on what C environment you are using such as VS2022, mingw, or cygwin with the most POSIX support on cygwin. Just look in the Standards section of the man page to see what it follows.
1
u/jwzumwalt Jan 02 '26 edited Jan 02 '26
You need to be smarter than the equipment you are operating!
People will tell you not to use scanf because they may not know how to
use it safely or too lazy to show you how it should be used safely.
2
u/[deleted] Dec 31 '25
[removed] — view removed comment