I'm working on TSP problem using ant colony optimization in C. I think that I implemented correctly, but my program doesn't work. I know that I had problems with memory in my code, because when I run my program the console write "core dumped." I used a gdb to find errors and when I wrote debugging commands I saw something like that:
Program received signal SIGSEGV, Segmentation fault.
0x08049691 in odleglosc (miastoA=1668848019, miastoB=1062464331, graf=0x804d440) at trail.c:34
34 return graf[miastoA][miastoB];
(gdb) bt
0 0x08049691 in odleglosc (miastoA=1668848019, miastoB=1062464331, graf=0x804d440) at trail.c:34
1 0x080496f1 in Length (sciezka3=0x804f5a0, graf=0x804d440, size=22) at trail.c:42
2 0x0804919d in updateFeromon (feromon=0x804f380, mrow=0x804e8a0, graf=0x804d440, parowanie=0, 10000000000000001, iloscFeromonu=2, miasta=22, mrowki=4) at pheromon.c:40
3 0x080489e3 in main (argc=1, argv=0xbffff0f4) at main.c:55
UpdateFeromon from pheromon.c calls a Length function from trail.c and next this function calls odleglosc also from trail.c. The range of miastoA and miasto is from 0 to 21. I dont know which function change my values ( miastoA and miastoB) and how to fix it.
This is a link to my code http://speedy.sh/FTTZe/mrowki.tar