Click here to Skip to main content
15,889,281 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Can someone give a detail of this sample coder why the result is 9,and not 4?? Pin
hasani200720-Jun-10 4:51
hasani200720-Jun-10 4:51 
AnswerRe: Can someone give a detail of this sample coder why the result is 9,and not 4?? PinPopular
Richard MacCutchan20-Jun-10 5:49
mveRichard MacCutchan20-Jun-10 5:49 
JokeRe: Can someone give a detail of this sample coder why the result is 9,and not 4?? Pin
Rajesh R Subramanian20-Jun-10 6:42
professionalRajesh R Subramanian20-Jun-10 6:42 
AnswerRe: Can someone give a detail of this sample coder why the result is 9,and not 4?? Pin
Hristo-Bojilov20-Jun-10 6:23
Hristo-Bojilov20-Jun-10 6:23 
GeneralRe: Can someone give a detail of this sample coder why the result is 9,and not 4?? Pin
Luc Pattyn20-Jun-10 11:04
sitebuilderLuc Pattyn20-Jun-10 11:04 
AnswerRe: Can someone give a detail of this sample coder why the result is 9,and not 4?? - sorta repost Pin
Iain Clarke, Warrior Programmer21-Jun-10 0:26
Iain Clarke, Warrior Programmer21-Jun-10 0:26 
QuestionHow to find the correct coordinate? Pin
hasani200720-Jun-10 4:28
hasani200720-Jun-10 4:28 
AnswerRe: How to find the correct coordinate? Pin
Niklas L21-Jun-10 0:44
Niklas L21-Jun-10 0:44 
Here are a few ideas for you to make life easier in the future:

1. Don't use global variables when you don't have to. In your case, wall might be acceptable, but dir should not be global.
2. Don't confuse others by writing wall[40][50] and only initialize 15/26.
3. If wall is global, add globals for the wall bounds as well. You don't want to use hard coded values (like 15 and 26) anywhere else but very close to you wall definition. (you can't trust sizeof() operator either the way you have done it)
4. Be consistent in your naming. Don't use indexes a and b in one place, and i and j in another for the same thing. x and y would do just fine.
5. Do not use labels and goto where a simple loop will be enough. Your code will be hard to follow and maintain, even if it's correct. If you need a label, and it will be a long time before you do, give it a meaningful name.
6. Let arrow_keys return its value instead of changing a global variable. It's defined to return an int, but never does. So is also create_wall() by the way.
7. Use constant identifiers instead of hard coded numbers. An enum type is well suited for your direction variable. Again, think of naming.
8. printf("%c", ...)? Have a look at putc().
9. Indentation looks a bit random, and so does placement of curly brackets. Adopt a consistent style.

That said, finding these kinds of bugs is an easy job if you step through the code in a debugger, inspecting indexes into your wall matrix.

But clean up your code first.

Questiona problem in maze (the worm pass the walls) Pin
hasani200720-Jun-10 0:25
hasani200720-Jun-10 0:25 
AnswerRe: a problem in maze (the worm pass the walls) Pin
Hristo-Bojilov20-Jun-10 0:45
Hristo-Bojilov20-Jun-10 0:45 
AnswerRe: a problem in maze (the worm pass the walls) Pin
Aescleal20-Jun-10 0:54
Aescleal20-Jun-10 0:54 
GeneralRe: a problem in maze (the worm pass the walls) Pin
hasani200720-Jun-10 1:10
hasani200720-Jun-10 1:10 
QuestionHow to get flash handle(ocx) in bho Pin
ZEROFIELD19-Jun-10 16:24
ZEROFIELD19-Jun-10 16:24 
AnswerCrosspost Pin
Richard MacCutchan19-Jun-10 21:28
mveRichard MacCutchan19-Jun-10 21:28 
QuestionWMI getting IP-Address [modified] Pin
Marcel Vogt19-Jun-10 4:23
Marcel Vogt19-Jun-10 4:23 
AnswerSuggestion Pin
Baltoro19-Jun-10 8:52
Baltoro19-Jun-10 8:52 
GeneralRe: Suggestion Pin
Marcel Vogt19-Jun-10 8:59
Marcel Vogt19-Jun-10 8:59 
GeneralRe: Suggestion Pin
Baltoro19-Jun-10 9:16
Baltoro19-Jun-10 9:16 
AnswerRe: WMI getting IP-Address Pin
Luc Pattyn19-Jun-10 9:26
sitebuilderLuc Pattyn19-Jun-10 9:26 
AnswerRe: WMI getting IP-Address Pin
Hristo-Bojilov20-Jun-10 3:44
Hristo-Bojilov20-Jun-10 3:44 
QuestionWhich is faster? Pin
Code-o-mat19-Jun-10 0:48
Code-o-mat19-Jun-10 0:48 
AnswerRe: Which is faster? Pin
Aescleal19-Jun-10 0:55
Aescleal19-Jun-10 0:55 
GeneralRe: Which is faster? Pin
Code-o-mat19-Jun-10 1:00
Code-o-mat19-Jun-10 1:00 
GeneralRe: Which is faster? [modified] Pin
Code-o-mat19-Jun-10 5:16
Code-o-mat19-Jun-10 5:16 
GeneralRe: Which is faster? Pin
Aescleal19-Jun-10 6:10
Aescleal19-Jun-10 6:10 

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.