C++ Programmer Question:
Download Job Interview Questions and Answers PDF
Tell me how can a C function be called in a C++ program?
![C++ Programmer Interview Answer C++ Programmer Interview Question](https://globalguideline.com/public/images/interview/28.png)
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);
}
Download C++ Programmer Interview Questions And Answers
PDF