C function prototype

Explain function prototype.

A function prototype is a mere declaration of a function. It is written just to specify that there is a function that exists in a program.

It is necessary to declare the return type and the arguments types along with their modifiers. However, it is not necessary to declare the names of the arguments.

Explain function prototype.

The basic definition of a function is known as function prototype. The signature of the function is same that of a normal function, except instead of containing code, it always ends with semicolon.

When the compiler makes a single pass over each and every file that is compiled. If a function call is encountered by the compiler, which is not yet been defined, the compiler throws an error.

One of the solution for the above is to restructure the program, in which all the functions appear only before they are called in another function.

Another solution is writing the function prototypes at the beginning of the file, which ensures the C compiler to read and process the function definitions, before there is a change of calling the function. If prototypes are declared, it is convenient and comfortable for the developer to write the code of those functions which are just the needed ones.
Purpose of "extern" keyword in a function declaration
The declaration of functions defaults to external linkage. The only other storage class possible for a function is static....
Use of fflush() function
In ANSI, fflush() [returns 0 if buffer successfully deleted / returns EOF on an error] causes the system to empty the buffer associated with the specified output stream.....
Difference between malloc() and calloc() function
malloc() and calloc() function - Both functions are used to dynamically allocate the memory. The difference is that calloc initializes the allocated memory to 0 or Null while malloc contains garbage values.....
Post your comment