Function overloading is that which allows us to have many functions with the same name but with different signatures. C language does not support function overloading as it is not Object Oriented. However, we can achieve the same functionality of function overloading in C indirectly.
rnMaking a void * type of pointer as an argument to the function and another argument telling the actual data type of the first argument that is being passed will help us achieve the functionality of function overloading indirectly.
rnint xyz(void * abc1, int abc2);
rnIf we want to call the function at different places, it is done as given below:
rnSuppose, abc2 can be interpreted as follows:
0 = Struct1 type variable, 1 = Struct2 type variable etc.
Here Struct1 and Struct2 are user-defined struct types.
rnfoo(abc1, 0); /*Here, abc1 is pointer to struct type Struct1 variable*/
foo(abc1, 1); /*Here, abc1 is pointer to struct type Struct2 variable*/
Since the second argument of the xyz keeps track of the data type of the first type, one can get the actual data type of the first argument by typecast accordingly inside the xyz function.