Function Declaration / Function Definition

Does it matter if the function definition is before int (main) or after int main?

I have seen this in both directions and am trying to find the right way to display function definitions and declarations.

+3
source share
4 answers

No, it is not. This is a matter of preference. Choose which you prefer and be consistent!

+6
source

A function definition (which contains the actual code) can be anywhere, even in another file, until a declaration (function prototype) appears before the function is called.

+2
source

. , ( ) .

, , . , main().

+1

. , ( 'prototype') , .

, . , , , .

0

Source: https://habr.com/ru/post/1769418/


All Articles