一个程序分开写出现问题
add.hint add(int a,int b);
add.c
#include"add.h"
int add(int a,int b)
{
int c;
return c = a + b;
}
add_main.cpp
#include<stdio.h>
#include"add.h"
int main()
{
int i,p,q;
scanf("%d %d",&i,&p);
q = add(i,p);
printf("i + p = %d",q);
return 0;
}
报错(编译没事,生成报错)
--------------------Configuration: add - Win32 Debug--------------------
Linking...
add_main.obj : error LNK2001: unresolved external symbol "int __cdecl add(int,int)" (?add@@YAHHH@Z)
Debug/add.exe : fatal error LNK1120: 1 unresolved externals
执行 link.exe 时出错.
add.exe - 1 error(s), 0 warning(s)