Click here to Skip to main content
15,902,635 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: unknown mistake Pin
aguest5-May-03 13:14
aguest5-May-03 13:14 
Generalanother problem Pin
aguest5-May-03 13:28
aguest5-May-03 13:28 
GeneralRe: another problem Pin
Chris Richardson6-May-03 5:16
Chris Richardson6-May-03 5:16 
GeneralLaunch a thread in a dll Pin
peter ho5-May-03 12:29
peter ho5-May-03 12:29 
GeneralRe: Launch a thread in a dll Pin
Trollslayer5-May-03 13:26
mentorTrollslayer5-May-03 13:26 
GeneralRe: Launch a thread in a dll Pin
Neville Franks6-May-03 1:39
Neville Franks6-May-03 1:39 
GeneralMaze program using recursive function UPDATED! Pin
lostlinkpr5-May-03 11:19
lostlinkpr5-May-03 11:19 
GeneralRe: Maze program using recursive function Pin
Nick Pirocanac5-May-03 11:48
Nick Pirocanac5-May-03 11:48 
Hello,

One problem I see right away is that when you pass maze to your recursive funcion, you are passing it as a pointer to the array, not a copy of the array. When you set a point in the maze matrix to 'x', you are setting it globally, so that the maze matrix is permantly altered. This means, that the more times you are calling your recursion function, you are setting more and more of your maze to all 'x', and removing the path of '.'. When dealing with arrays in C/C++, you will always pass them as pointers to the underlying data, as opposed to passing a copy. If you want to stick with the method you are using above, you would have to make a new copy of the maze matrix before calling solve_maze each time. Check out the docs for memcpy()!

maze[12][12];
newMaze[12][12];

memcpy(newMaze, maze, sizeof(newMaze));

// Do your switch to make the move, and apply the changes to the newMaze copy

solve_maze(newMaze, ...);


Note: Solving a huge maze with this method will eat a lot of memory, as you will make a new copy on each recusion level, leading to lots of copys when you get down deep in your tree.

Good luck!


Nick.
GeneralRe: Maze program using recursive function Pin
Sean Cundiff5-May-03 11:49
Sean Cundiff5-May-03 11:49 
GeneralRe: Maze program using recursive function Pin
Joaquín M López Muñoz5-May-03 11:54
Joaquín M López Muñoz5-May-03 11:54 
GeneralDialog Question Pin
bmxracer5-May-03 10:54
bmxracer5-May-03 10:54 
GeneralRe: Dialog Question Pin
Ravi Bhavnani5-May-03 11:02
professionalRavi Bhavnani5-May-03 11:02 
GeneralRe: Dialog Question Pin
bmxracer5-May-03 11:34
bmxracer5-May-03 11:34 
GeneralRe: Dialog Question Pin
Chris Richardson5-May-03 12:46
Chris Richardson5-May-03 12:46 
GeneralRe: Dialog Question Pin
bmxracer5-May-03 15:45
bmxracer5-May-03 15:45 
GeneralRe: Dialog Question Pin
bmxracer5-May-03 17:21
bmxracer5-May-03 17:21 
GeneralRe: Dialog Question Pin
Joan M5-May-03 21:14
professionalJoan M5-May-03 21:14 
Questionvariable row height in ListView ? Pin
JohnMcL5-May-03 10:02
JohnMcL5-May-03 10:02 
AnswerRe: variable row height in ListView ? Pin
valikac5-May-03 11:18
valikac5-May-03 11:18 
GeneralRe: variable row height in ListView ? Pin
JohnMcL5-May-03 13:38
JohnMcL5-May-03 13:38 
Generaldialog apps Pin
dave_long5-May-03 9:44
dave_long5-May-03 9:44 
GeneralRe: dialog apps Pin
Joaquín M López Muñoz5-May-03 9:53
Joaquín M López Muñoz5-May-03 9:53 
GeneralGDI+ problem Pin
Alex Boyce5-May-03 9:37
Alex Boyce5-May-03 9:37 
GeneralError handling Pin
Jerome Conus5-May-03 8:53
Jerome Conus5-May-03 8:53 
GeneralRe: Error handling Pin
valikac5-May-03 9:09
valikac5-May-03 9:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.