In the code I am writing I need foo(int, char*) and foo(int, int) functions.
If I was coding this in C++ I would use templates. Is there any equivalent for C? Or should I use void pointers? How?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t do that.
In C there are no overloads, one function, one name, you’ll need to use a type that supports all your needs, e.g. (void *)
Either that or do a
foo_int(int,int)and afoo_char(int, char*)