Array - how can I skip a repeated value in an array?
#9

You should loop through found categories instead of all previous categories while working with large arrays (as you mentioned this is for a furniture system? fyi: not on this thread).

Sample:
PHP код:
enum e_array
{
    
something_1,
    
something_2,
    
something_3[40],
    
category[20]
};

new array[][
e_array] =
{
    {
0380"asdfafa""Other"},
    {
0578"asdfafafdsafa""Other"},
    {
0578"asdfafafdxsafasfadwada""Another"},
    {
0578"asdfafafdxsafasfawadaaasd""Another"},
    {
0578"asdfafafdxsafasfawadaaasdfff""Test Something"},
    {
0578"asdfafafdxsafasfawadaaasdffffawfwa""Another Test"},
    {
0578"asdfafafdxsafasfawadaaasd""Test"},
    {
0578"asdfafafdxsafasfawadaaasd""Another"},
    {
0380"asdfafa""Test"}
};

main()
{
    new 
categories[10][20];
    for(new 
0sizeof(array), countbool:duplicatej++, duplicate false)
    {
        for(new 
0categories[k][0] != EOS++)
        {
            if(!
strcmp(array[i][category], categories[k], false))
            {
                
duplicate true;
                break;
            }
        }

        if(!
duplicate)
        {
            
strcat(categories[count ++], array[i][category], 20);

            
printf("%d %s"i, array[i][category]);
        }
    }

Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 4 Guest(s)