C++ Programmer Question:
Tell me how can a C function be called in a C++ program?
Answer:
Using an extern "C" declaration:
//C code
void func(int i)
{
//code
}
void print(int i)
{
//code
}
//C++ code
extern "C"{
void func(int i);
void print(int i);
}
void myfunc(int i)
{
func(i);
print(i);
}
//C code
void func(int i)
{
//code
}
void print(int i)
{
//code
}
//C++ code
extern "C"{
void func(int i);
void print(int i);
}
void myfunc(int i)
{
func(i);
print(i);
}