Resending the query with code tags.

Intersection of two strings
Hi,

Could someone tell me if there's a better way of doing this? I was asked this question in an interview and I wrote a piece of code of O(n2).

// This function returns a new string of the common alphabets found in a and b
Quote:
char* intersection(char*a, char* b)
{
static char temp[20];
int i = 0;
if ( (a==NULL) || (b==NULL))
exit(0);
else
{
while ( a != NULL)
{
if(strchr(b, *a))
{
temp[i] = *a;
i++;
a++;
}
}
}

return temp;
}
Thanks,
Tina