Code:
int not_finished = 1;
int iterations = 0;
while(not_finished == 1)
{
/* This is the printf statement that gets everything to work */
/* for(int i = 0; i < MAX_NUM_NODES; i++)
{
printf("Node: %c Previous: %c Costs: %f Status: %c\n", nodes[i], previous[i], costs[i], status[i]);
} */
iterations ++;
printf("While loop %i times\n", iterations);
for(int counter1 = 0; counter1 < MAX_SEGMENTS; counter1++)
{
if((start[counter1] == curr_node) && (start[counter1] != 33))
{
for(int counter2 = 0; counter2 < MAX_NUM_NODES; counter2 ++)
{
if((nodes[counter2] == end[counter1]) && (costs[counter2] >= consumption[counter1] + costs[node_pos]))
{
previous[counter2] = curr_node;
costs[counter2] = costs[node_pos] + consumption[counter1];
}
}
}
if((end[counter1] == curr_node) && (start[counter1] != 33))
{
for(int counter3 = 0; counter3 < MAX_NUM_NODES; counter3 ++)
{
if((nodes[counter3] == start[counter1]) && (costs[counter3] >= consumption[counter1] + costs[node_pos]))
{
previous[counter3] = curr_node;
costs[counter3] = costs[node_pos] + consumption[counter1];
}
}
}
}
/* for(int i = 0; i < MAX_NUM_NODES; i++)
{
printf("Node: %c Previous: %c Costs: %f Status: %c\n", nodes[i], previous[i], costs[i], status[i]);
} */
node_pos = costcomp(costs, status);
printf("Node_pos: %d\n", node_pos);
curr_node = nodes[node_pos];
printf("Currentnode : %c\n", curr_node); /* STOPS HERE */
status[node_pos] = 49;
if(curr_node == destination)
{
not_finished = 0;
}
}
this is the code...