Is it better to write the void funtion before the main funtion, or write it below the main function and mention it "prototype" it before the main?

I know both works, but im wondering if the program uses a bit more time searching for it when its below the main function

Recommended Answers

All 3 Replies

By the time your program is in binary form the location is known and it is an absolute jump to address. The only time this would matter (if at all) is the compilation stage. I'd argue that unless all time is dominated by compilation time you shouldn't need to worry about it.

Thank you

Doesn't matter. I usually first declare a prototype and then function underneath main but it is so it will be easier to scroll through main. And the best way is to make an additional file for other functions that are not in main. You will have to include the header file and you will put prototype declaration in header file and include like this " " it in every file you are using for your program

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.