segmentation fault

The usual segmentation fault..the debugger takes me to the line
for(combi * put = head ...........

am thinking head does not exist...which means call to function ins(head, t, f) is not working properly..everything compiles fine though..
but I don't know how to solve this problem...

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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
 void make_two_sures (int & start1, std::vector<int> cross)
{
 int sz = cross.size();

for (int p = 0; p != sz; p++)
   {  for(int pt = p+1; pt != sz; pt++)
      {if (cross[p] != cross[pt])
           {
              int f = cross[p] ;
              int t = cross[pt];
              ins( head, f, t );

           }
      }
   }
int si = 0;

   for( combi * put = head; put->nextPtr != 0; put = put->nextPtr)
      {
       int n = 0;
       int f_val = put->valore;
       int s_val = put->valor;
         for ( int r = start1; r < ROW-(Minus); r++)
              {
                if(
                    (LN[r][0] == f_val   || LN[r][1]== f_val    ||LN[r][2]== f_val
                    ||LN[r][3]== f_val   || LN[r][4]== f_val )
                     &&
                    (LN[r][0] ==   s_val   || LN[r][1]==  s_val    ||LN[r][2]==  s_val
                     ||LN[r][3]==  s_val ||LN[r][4]==  s_val)
                  )

                  {
                  n++;
                  si++;
                  ins(head1, put->valore, put->valor);
                  }
              }

       }

 for (combi*ptr = head1; ptr->nextPtr != 0 ; ptr = ptr->nextPtr)
     { int a = ptr->valore;
       int b = ptr->valor;
       std::pair<int ,int> two_sure( a, b);
       Two_sures.insert(two_sure);
     }

 }


void ins(combi * &testa, int numero,int num)

{  //     if (ricerca(testa, numero) == 0)

        //{
               combi  *temp = new combi;

                temp->valore = numero;
                temp->valor = num;
                temp->nextPtr = 0;

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

   
}

void list_two_sures()
{
 std::cout<<" Hello Mike, the confirmed two sures for todays game are "<< Two_sures.size() <<endl<<" and they are "<<endl;

for( auto s : Two_sures)
 std::cout<<"("<<s.first<<","<<s.second<<") ";
Last edited on
closed account (SECMoG1T)
Provide all your code , this ain't enough to figure oit your problem.
Last edited on
Topic archived. No new replies allowed.