Category: Functions in C

Functions in C

sprintf function

sprintf function

sprintf composes a string with the same text that would be printed if format was used on printf, but instead of being printed, the content is stored as a C string in the buffer...

Variable Length Arguments in C

Variable Length Arguments in C

C allows you to define functions that you can call with a variable number of arguments. These are sometimes called variadic functions. Such functions require a fixed number of mandatory arguments, followed by a...

Recursion

Recursion

In C, it is possible for the functions to call themselves. A function is called ‘recursive’ if a statement within the body of a function calls the same function. Sometimes called ‘circular definition’, recursion...

Inline Functions in C

Inline Functions in C

Ordinarily, calling a function causes the computer to save its current instruction address, jump to the function called and execute it, then make the return jump to the saved address. With small functions that...

Call by reference

Call by reference

In call-by-reference evaluation (also referred to as pass-by-reference), a function receives an implicit reference to a variable used as argument, rather than a copy of its value. This typically means that the function can...

Call by Value

Call by Value

Call by value is a value passing mechanism to function in which a value is passed to some function and the function is not responsible for midifying the passed value. If the function modifies...

Passing Values between Functions

Passing Values between Functions

The functions that we have used so far haven’t been very flexible. We call them and they do what they are designed to do. Like our mechanic who always services the motorbike in exactly...

Calling Multiple Functions

Calling Multiple Functions

If you have grasped the concept of ‘calling’ a function you are prepared for a call to more than one function. Consider the following example: Example

Reviewing Functions

Reviewing Functions

First, what is a function? A function is a self-contained unit of program code designed to accomplish a particular task. A function in C plays the same role that functions, subroutines, and procedures play...