Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Avoid duplication in array

Status
Not open for further replies.

swaroop

Programmer
Feb 4, 2001
100
US
Some one Please help me.

I need a program to Avoid duplication in charector array.

Thanks in advance.

Swaroop.
 
I would think a sorted array would be the best bet, maybe with an insertion sort. Or maybe somethng like

char current[128];
char lookFor[2];
memset(lookFor,0,2);

lookFor[0]= character;
if(!strstr(buffer,lookFor))
{
insert it
}

<Matt
 
How about a binary search tree instead? The other way is to spend the time and do the compare on each item.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top