zero in list contents and multiset contents

so i insert values from a vector into a list and into a multiset,
and i noticed zero is added to their contents!
I had to do a whole lot of debugging to find out where the error was, how can i stop this thing?
am gonna try to post a part of my code which generates such error...

infact i checked the content of vector ups to be sure there was no zero in it,
but after loading into list combi_t * head, it seems like there was a zero added and this is giving me errors when i call function master_roller...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
void ins(combi_t * &testa, int &numero, int &num, int &no)
{  //     if (ricerca(testa, numero) == 0)

        //{
               combi_t  *temp = new combi_t;

                temp->val0 = numero;
                temp->val1 = num;
                temp->val2 = no;
                temp->nextPtr = 0;

               if (testa==0) testa=temp;
               else
              {
                combi_t *curr=testa;
               while (curr->nextPtr!=0) curr=curr->nextPtr;
                curr->nextPtr = temp;
               }
}


void make_three_sures (std::vector<int> & cross)
{
for (int p = 0; p < cross.size(); p++)
   {  for(int pt = (p+1); pt != cross.size(); pt++)

      { if (pt>cross.size()) break;;
      ins(head, cross[p], cross[pt], cross[pt+1]);
      }
   }


}


 std::cout<<"Ups size is"<<ups.size()<<endl;
for(int n : ups){cout<<" "<<n<<", ";}
      make_three_sures(ups);
      for (combi_t* ptr = head; ptr->nextPtr != 0 ; ptr = ptr->nextPtr)
          {
           master_roller(ptr->val0, ptr->val1, ptr->val2, num);
           num--;
          }
Last edited on
> so i insert values from a vector into a list and into a multiset,
there is no mention of a multiset in your code

> and i noticed zero is added to their contents!
¿how did you check that?

> am gonna try to post a part of my code which generates such error...
in order for your code to generate the error, we should be able to compile and run it and get the erroneous output that you mention.
Anything else is useless.

> but after loading into list combi_t * head,
¿why aren't you using std::list?

> is giving me errors when i call function master_roller...
«giving errors» is not descriptive
also, you haven't posted the master_roller function
ok sorry and thank you ne555...I somewhat solved it and i will use std::list instead of writing my own thanks
Topic archived. No new replies allowed.