Concept
What capabilities and constraints do functions have in C?
ComputerScienceOne / Declaration: Prototypes
"As a procedural-style language, functions are essential in C programming. As we’ve already seen, C provides a large library of standard functions to perform basic input/output, math, and many other functions. C also provides the ability to define and use your own functions. When you define functions in C, careful thought must be made as to the naming of your functions. This is because C does not support function overloading. When you name a function, that is the only function that can have that name. Consequently, you cannot, in general, use the same function names as defined in the standard libraries or any other 3rd party library that you would like to use in your programs. C supports both call by value and call by reference using pointers (see Section 18.2). C also supports vararg functions (printf() being a prime example) and allows you to define vararg functions, but we will not cover them in depth here. Finally, parameters are not, in general, optional. For modern versions of C the omission of parameters is a syntax error. For older versions, complex rules dictate what happens when arguments are omitted, but doing so usually results in garbage."
Related Ideas
- How do pointers pass values by reference in C?ComputerScienceOne · Function Pointers
- How are void functions defined in C?ComputerScienceOne · Void Functions
- What information does a C function prototype specify?ComputerScienceOne · Declaration: Prototypes
- How do C functions return values to the calling function?ComputerScienceOne · Void Functions
- How is a C function prototype turned into a function definition?ComputerScienceOne · Declaration: Prototypes
- How do you call functions in C?ComputerScienceOne · Organizing Functions
- What is a function pointer and how is it declared?ComputerScienceOne · Function Pointers
- How do header and source files organize functions in C?ComputerScienceOne · Calling Functions