Hey all,
I am having some segmentation issues. Basically main() reads in a text file, and stores the necessary information in a 2d array. It reads and passes the necessary information to FindPath() on a line-by-line basis.
Sample input file:
Code:
2
4
1 2 4 2 2 2
2 1 4 2 2 3
2 2 4 2 2 1
-1 -1 -1 -1 -1 -1
First line is saying I have a 2x2 grid map and the second a 4 tracks. The remaining three strings of numbers are basically description of element placements on the 2x2 map. Example: 1 2 4 2 2 2 says element (1,2) has outlet 4 connected to inlet 2 of element (2,2). This file can of course have hundreds of such lines describing element placement. -1 -1...-1 means the end of the file
When main() successfully passes the third line (1 2 4 2 2 2), the called function to an extent does its job, but there is a seg fault before the main() can pass the information of the remaining lines to the called function.
Source code: C pastebin - collaborative debugging tool
Sample output:
Code:
grid is 2
main passing 1,2 2,2
parentXval is 1 parentYval is 2
a = 0. b = 1
Cost 0,1 is 44
a = 1. b = 1
Cost 1,1 is 30
a = 2. b = 1
a = 0. b = 2
Cost 0,2 is 30
a = 1. b = 2
a = 2. b = 2
Cost 2,2 is 10
a = 0. b = 3
a = 1. b = 3
a = 2. b = 3
Parent is 1,2
Logical length from 1,2 is 1
Segmentation fault
Any help would be appreciated.