Function Prototype in C

Ali Farzanrad
1 min readApr 3, 2020

Many programmers already know about header files and function declarations; however only few ones might know about different types of function declarations. There are 2 types of function declarations: function declaration without prototypes, and function declaration with prototypes.

When you declare a function without prototype, compiler doesn’t know anything about parameter types; so it may not help you by converting arguments to the right types and user is responsible for providing arguments with right types when calling a function. In the following valid C program, as you can see, I’ve called two functions in some wrong ways but compiler will not prevent me.

It’s a really bad programming practice, isn’t it? Well, you can declare a function with prototype. In this type of declaration you provide type of all parameters to the compiler; so compiler can now prevent you from invalid calls to functions.

So as you can see whenever you declare a function with nothing inside parenthesis, you declare that function without prototype. That’s why it is recommended to always specify void for parameter-less function declarations.