C FunctionsLesson 27Free preview
C Function Declaration
This lesson is part of C · All levels
Summary
A declaration (prototipe) is a statement on a file that tells the compiler about the name of the function, the type of return, and the parameters without having to write the contents of the body. With a prototype, a function can be defined at the bottom of a file even if it can still be called from play. The prototype ends with a semicolon and must be consistent with the function definition. This practice makes the layout of the code more neat and prevents undetected parameter type errors.
Key points
- Prototype is shaped: type nama(tipe param, ...); and ends with semicolon
- The prototype allows naming a function defined afterwards.
- A mismatch of the prototype with the definition resulted in an error/warning compiler
- Placing a prototype in a header along with a function is often used in multi-file projects
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.