Why should I prototype a function?

A function prototype tells the compiler what kind of arguments a function is looking to receive and what kind of return value a function is going to give back. This approach helps the compiler ensure that calls to a function are made correctly and that no erroneous type conversions are taking place.

Showing Answers 1 - 3 of 3 Answers

Have_Phun

  • Feb 3rd, 2007
 

int foo(int); // This is func. prototype//Below is func. definitionint foo(int param) { int ret_val; retval=param*100;// return ret_val;}A prototype enables the compiler to know the existence of a certain function somewhere in the program.Whereas the function definition tells it's logic.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions