Just count how many interfaces you have, and if you only have one, then use it rather than prompting for it:
int count = 0;
while (local->h_addr_list[count] != 0)
count++
if (count == 1)
{
in = 0;
}
else
}
for (i = 0; local->h_addr_list[i] != 0; ++i)
{
memcpy(&addr, local->h_addr_list[i], sizeof(struct in_addr));
printf("Interface Number : %d Address : %s\n",i,inet_ntoa(addr));
}
printf("Enter the interface number you would like to sniff : ");
scanf("%d",&in);
}