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

C / C++ / MFC

 
GeneralRe: What's problem of my code?( create a random maze) Pin
jiuyejii6-Jun-12 1:36
jiuyejii6-Jun-12 1:36 
SuggestionRe: What's problem of my code?( create a random maze) Pin
David Crow6-Jun-12 2:36
David Crow6-Jun-12 2:36 
AnswerRe: What's problem of my code?( create a random maze) Pin
Maximilien6-Jun-12 2:46
Maximilien6-Jun-12 2:46 
AnswerRe: What's problem of my code?( create a random maze) Pin
Aescleal6-Jun-12 6:47
Aescleal6-Jun-12 6:47 
GeneralRe: What's problem of my code?( create a random maze) Pin
Peter_in_27806-Jun-12 17:37
professionalPeter_in_27806-Jun-12 17:37 
GeneralRe: What's problem of my code?( create a random maze) Pin
jiuyejii6-Jun-12 18:49
jiuyejii6-Jun-12 18:49 
GeneralRe: What's problem of my code?( create a random maze) Pin
Aescleal6-Jun-12 23:52
Aescleal6-Jun-12 23:52 
AnswerRe: What's problem of my code?( create a random maze) Pin
Stefan_Lang8-Jun-12 4:19
Stefan_Lang8-Jun-12 4:19 
The problem is right at the end of the function cmaze(): there you call the same function, recursively. That means for every step, your program will push one more function call on the stack, and it won't resolve it until the very end.

Don't do that kind of thing. Instead use the return code to indicate whetehr or not you need to do another step, and create a loop:

Change the function cmaze to:
C++
bool cmaze(int& i, int& j) {
   //...
   // change your test for the exit to the following:
   if (maze[out][N]=='.')
      return false;

   // ... the rest of your code

   // and at the end:
   return true;
}

Change your call to cmaze in makebg() to:
C++
i = in;
j = 1;
while (cmaze(i, j));

GeneralRe: What's problem of my code?( create a random maze) Pin
jiuyejii8-Jun-12 17:57
jiuyejii8-Jun-12 17:57 
QuestionMFC application being compiled on VS2012 Pin
YaronNir5-Jun-12 23:03
YaronNir5-Jun-12 23:03 
QuestionRe: MFC application being compiled on VS2012 Pin
David Crow6-Jun-12 2:37
David Crow6-Jun-12 2:37 
AnswerRe: MFC application being compiled on VS2012 Pin
YaronNir6-Jun-12 2:40
YaronNir6-Jun-12 2:40 
GeneralRe: MFC application being compiled on VS2012 Pin
tldcolli4-Aug-12 3:31
tldcolli4-Aug-12 3:31 
AnswerRe: MFC application being compiled on VS2012 Pin
tldcolli4-Aug-12 3:28
tldcolli4-Aug-12 3:28 
QuestionCode Executed Twice - OnHScroll() Pin
AmbiguousName5-Jun-12 21:42
AmbiguousName5-Jun-12 21:42 
AnswerRe: Code Executed Twice - OnHScroll() Pin
Chris Losinger6-Jun-12 1:17
professionalChris Losinger6-Jun-12 1:17 
AnswerRe: Code Executed Twice - OnHScroll() Pin
AmbiguousName6-Jun-12 1:35
AmbiguousName6-Jun-12 1:35 
GeneralRe: Code Executed Twice - OnHScroll() Pin
Chris Losinger6-Jun-12 1:38
professionalChris Losinger6-Jun-12 1:38 
GeneralRe: Code Executed Twice - OnHScroll() Pin
AmbiguousName6-Jun-12 1:40
AmbiguousName6-Jun-12 1:40 
GeneralRe: Code Executed Twice - OnHScroll() Pin
Chris Losinger6-Jun-12 2:08
professionalChris Losinger6-Jun-12 2:08 
AnswerRe: Code Executed Twice - OnHScroll() Pin
Malli_S6-Jun-12 21:43
Malli_S6-Jun-12 21:43 
SuggestionRe: Code Executed Twice - OnHScroll() Pin
David Crow6-Jun-12 2:40
David Crow6-Jun-12 2:40 
QuestionHow to stop indexing from restarting? Pin
Wolfkc5-Jun-12 12:14
professionalWolfkc5-Jun-12 12:14 
AnswerRe: How to stop indexing from restarting? Pin
enhzflep5-Jun-12 16:01
enhzflep5-Jun-12 16:01 
QuestionRe: How to stop indexing from restarting? Pin
David Crow6-Jun-12 2:41
David Crow6-Jun-12 2:41 

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.