-
Code:
points[1][1] = 1;
points[1][2] = 2;
points[1][3] = 3;
points[1][4] = 4;
points[2][1] = 5;
points[2][2] = 6;
points[2][3] = 7;
points[2][4] = 8;
points[3][1] = 9;
points[3][2] = 10;
points[3][3] = 11;
points[3][4] = 12;
nextpoint[1][1] = 1;
nextpoint[1][2] = 2;
nextpoint[1][3] = 3;
nextpoint[1][4] = 4;
nextpoint[2][1] = 5;
nextpoint[2][2] = 6;
nextpoint[2][3] = 7;
nextpoint[2][4] = 8;
nextpoint[3][1] = 9;
nextpoint[3][2] = 10;
nextpoint[3][3] = 11;
nextpoint[3][4] = 12;
Arrays indices in C++ start at 0, so you must either expand your array, or change your initialization.
> int points[3][4];
This array goes from [0 thru 2][0 thru 3], so:
Code:
points[0][0] = 1;
points[0][1] = 2;
points[0][2] = 3;
points[0][3] = 4;
points[1][0] = 5;
points[1][1] = 6;
points[1][2] = 7;
points[1][3] = 8;
points[2][0] = 9;
points[2][1] = 10;
points[2][2] = 11;
points[2][3] = 12;
nextpoint[0][0] = 1;
nextpoint[0][1] = 2;
nextpoint[0][2] = 3;
nextpoint[0][3] = 4;
nextpoint[1][0] = 5;
nextpoint[1][1] = 6;
nextpoint[1][2] = 7;
nextpoint[1][3] = 8;
nextpoint[2][0] = 9;
nextpoint[2][1] = 10;
nextpoint[2][2] = 11;
nextpoint[2][3] = 12;
-
Also since you're checking attempt back in main(), you should pass this as a reference:
void directionfunct(int &x, int &y, int coords[][13], int &letters, int ans,int cx, int cy, int j, int answer[12], int &ax, int &ay, int &attempt )
-
Actually you may need to pass everything as a reference:
void directionfunct(int &x, int &y, int coords[][13], int &letters, int &ans,int &cx, int &cy, int &j, int answer[12], int &ax, int &ay, int &attempt)
-
Personally, I'd say that function (directionfunct) has way too many parameters. Also, the names of the parameters looks way to confusing too. But hey, it's your prog ;)
-
Yes, it does have a lot of parameters, that is because I want to increment and decrement things, and it would be harder to do if the declaration is inside of the loop.
I guess I will increase the array, I just like to start at 1.
-
Just posting the updated code before I stop programming for tonight.