I have a function, can write in 2 ways.
void function(void) {
// operations....
}
and
void function() {
// operations......
}
Both functions are of same prototype. Why we have to mention void as argument at function definition?
No, both have different prototypes.
Compile the below programs you will understand.
void function1(void)
{
printf("In function1\n");
}
void function2()
{
printf("In function2\n");
}
int main()
{
function1();
function2(100); //Won't produce any error
return 0;
}
Program 2:
#include <stdio.h>
void function1(void)
{
printf("In function1\n");
}
void function2()
{
printf("In function2\n");
}
int main()
{
function1(100); //produces an error
function2();
return 0;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With