Im very new to C programing, but have limited experience with Python, Java, and Perl. I was just wondering what the advantage is of having the prototype of a function above main() and the definition of that function below main() rather than just having the definition of said function above main(). From what I have read, the definition can act as a prototype as well.
Thanks in advance,
The use of a prototype above
main()(within a single module) is mostly a matter of personal preference. Some people like to seemain()at the bottom of the file; other people like to see it at the top. I had a professor in university who complained that I wrote my programs “upside-down” because I putmain()at the bottom (and avoided having to write and maintain prototypes for everything).There is one situation where a prototype may be required:
In this mutually recursive situation, you need at least one of the prototypes to appear prior to the definition of the other function.