Let's assume I want to create a function first
that returns the first element of an array in C. Obviously I want to create something that accounts for all types.
I would start with this:
int first(int list[]) {
return list[0];
}
Which works. Obviously...
I would now like to do the same for char
char first(char list[]) {
return list[0];
}
Which does not compile as there is already a first
function in the program.
How do you C guys handle this kind of scenarios?
Is one forced to go with different names?
int first_int(int list[]) {
return list[0];
}
char first_char(char list[]) {
return list[0];
}