Thanks for your reply.
Ok, that was a poorly thought out example. Maybe that isn't the problem.
I tried to make an example because it'd take ages to explain what the entire purpose of this code is. I have cut out the relevant parts of the code and placed them below. The array road_type holds 0's 1's and 2's in a random order, it's total size is num_roads.
Code:
#include <stdio.h>
#include <stdlib.h>
#define INTO 0
#define OUTOF 1
#define TWOWAY 2
/* Prototypes of local functions */
int get_route_list(int num_roads, int num_routes, int *road_type, int y, int x);
int main(int argc, char *argv[])
{
/* Create an integer array showing possible routes i.e. road 1 to road 4 would be 14 */
int j;
int route_list[num_routes][1];
for(j = 0; j < num_routes; j++)
{
route_list[j][0] = get_route_list(num_roads, num_routes, road_type, j, 0);
route_list[j][1] = get_route_list(num_roads, num_routes, road_type, j, 1);
}
/* -----------------end route list thing-------------------*/
return 0;
}
/* Create an array that lists the possible routes */
int get_route_list(int num_roads, int num_routes, int *road_type, int y, int x)
{
int i, j;
int route_list[num_routes][1];
int place_holder = 0;
for(i = 0; i <= num_roads; i++)
{
if(road_type[i] == TWOWAY || road_type[i] == INTO)
{
for(j = 0; j <= num_roads; j++)
{
if(road_type[j] == TWOWAY || road_type[j] == OUTOF)
{
if(i == j)
{}
else
{
route_list[place_holder][0] = i;
route_list[place_holder][1] = j;
/* #_#_#_#_#_#_#_#_# */
place_holder++;
}
}
}
}
}
return route_list[y][x];
}
At that point where the #_#_ bit is the route list array is working fine for the first loop of that j for loop. Then when it loops through again i get problems, the program seems to assign the value of i to the route_list[place_holder][1] = j; I cant work out why this is.
I'm struggling to explain this without posting the whole code and assignment details. If there is an obvious problem then it'd be great to hear what it is. Otherwise i'll just bang my head against the wall for another couple of hours and hope an answer falls out
-Nick