Function prototype declared inside main - best practice?

前端 未结 5 1021
心在旅途
心在旅途 2020-12-03 18:09

Is this a good style to have the function prototype declared inside of the main function?

I was looking at a C tutorial, I think is quite out of date. However, they

5条回答
  •  天涯浪人
    2020-12-03 18:55

    It's not a good style.

    Either declare the local function prototypes at the beginning or move them to a header-file.

    Function protoypes (and external variables as well) can be declared almost everywhere in the c-language. However, just because it's possible shouldn't be no reason to write spaghetti style C.

    It makes the code less readable. For me such practices are a clear sign of code-smell.

提交回复
热议问题