编译通过哦
可是link时出了这个问题,这是为什么啊?
195759_0_5717.cpp
195759_0_5717.obj : error LNK2001: unresolved external symbol "void __cdecl operating(struct people_gate *,int)" (?operating@@YAXPAUpeople_gate@@H@Z)
195759_0_5717.exe : fatal error LNK1120: 1 unresolved externals
附代码如下:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef struct people_gate
{
char num[20];
int come_time;
int leave_time;
}gate;
typedef struct peo_gate
{
char num[20];
int time;
}out_gate;
int cmp(const void *p,const void *q);
void operating(gate *,int);
int main()
{
int n;
int m;
int i;
int come_h=0,come_m=0,come_s=0,leave_h=0,leave_m=0,leave_s=0;
gate * ptgate;
while(scanf("%d",&n)!=EOF)
{
for(;n>0;n--)
{
scanf("%d",&m);
ptgate=(gate *)malloc(m*sizeof(gate));
for(i=0;i<m;i++)
{
scanf("%s %d:%d:%d %d:%d:%d",(ptgate+i)->num,come_h,come_m,come_s,leave_h,leave_m,leave_s);
(ptgate+i)->come_time=3600*come_h+60*come_m+come_s;
(ptgate+i)->leave_time=3600*leave_h+60*leave_m+leave_s;
}
operating(ptgate,m);
}
}
return 0;
}
int cmp(const void *p,const void *q)
{
return ((((out_gate *)p)->time)-(((out_gate *)q)->time));
}
void opearating(gate * ptgate,int m)
{
int i;
out_gate * pg[2];
for(i=0;i<2;i++)
pg[i]=(out_gate *)malloc(m*sizeof(out_gate));
for(i=0;i<m;i++)
{
strcpy((pg[0]+i)->num,((ptgate+i)->num));
(pg[0]+i)->time=(ptgate+i)->come_time;
}
for(i=0;i<m;i++)
{
strcpy((pg[1]+i)->num,((ptgate+i)->num));
(pg[1]+i)->time=(ptgate+i)->leave_time;
}
qsort(pg[0],m,sizeof(out_gate),cmp);
qsort(pg[1],m,sizeof(out_gate),cmp);
printf("%s %s\n",pg[0]->num,(pg[1]+m-1)->num);
}