NEEd help with this code to sort array of structure. Please. Debug it

#include <stdio.h>
#include <stdlib.h>
inline int compare(const void * p, const void q)
{
struct guest
ip=(struct guest*)p;
struct guest* iq=(struct guest*)q;
return( (ip->a)-(iq->a) );
}
struct guest
{
int a;
int d;
} g[100];

int main(void) 
{
	int t,n,i;
	
	
	scanf("%d",&t);
	while(t--)
	{
		scanf("%d",&n);
		for(i=0;i<n;i++)
		{
			scanf("%d",&g[i].a);
		}
		for(i=0;i<n;i++)
		{
			scanf("%d",&g[i].d);
		}
		
		qsort(g,n,sizeof(struct guest),compare);
		
		for(i=0;i<n;i++)
		{
			printf("%d ",g[i].a);
		
			printf("%d\n",g[i].d);
		}
	}
	return 0;
}

(struct guest *)p – in the compare function. Everything else seems fine