main.cpp
#include <iostream>
#include"test.h"
using namespace std;
//在C++中想调用C中的函数
//extern "C" void show(); //一个一个函数调用的方法
int main()
{
show();
return 0;
}
test.h
#ifndef TEST_H_INCLUDED
#define TEST_H_INCLUDED
//加上下面这段话
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
#include <stdio.h>
void show();
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // TEST_H_INCLUDED
test.c
#include<stdio.h>
#include "test.h"
//函数的具体实现
void show()
{
printf("Hello world!\n");
}