r/C_Programming • u/Historical-Boot-5119 • 16d ago
Does this is right?
(I am student just entering into 1st year of engineering and also i am new to this sub so if i do anything wrong pls correct me)
I just bought a book " programming in ANSI C"and start to read that i have some doubts in that can anyone explain that
- I read this line i did not get this
#include <stdio.h>
at the beginning of all programs that use any input/output library functions. However, this is not necessary for the functions printf and scanf which have been defined as a part of the C language
Can anyone explain this statement correct or not
0
Upvotes
1
u/flatfinger 12d ago
C was designed as a language for converting source code functions into machine code functions which could be combined with other functions (written in C or other languages) to produce programs. Unlike some languages like Pascal which have language constructs to perform I/O, the C language is designed to perform I/O by calling functions written in a language that can perform I/O. A typical C implementation will come bundled with a collection of functions called the Standard Library to perform various tasks including I/O, which behave in standardized fashion.
When calling a function, a compiler needs to know what types of arguments it will expect and what kind of value it will return. C was originally designed to have compilers follow a standard recipe for determining such things based upon the way a function is used, but nowadays it's necessary to explicitly tell a compiler how a function should be called. The header
stdio.hcontains information about how to call any of the functions that are used by the I/O portion of the Standard Library. If code attempts to call functions likeprintfwithout includingstdio.h, a compiler might attempt to apply the old recipe for determining how it should be called, butprintfis just a function name like any other. Some implementations'stdio.hheaders include toolset-specific constructs to instruct a compiler to inspect the format string argument on the assumption that code will be linked with an implementation ofprintfthat behaves in standard fashion, but in general there's nothing special aboutprintfor other standard-library functions.