Click here to Skip to main content
15,885,757 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Exception handler Pin
SeeSharp214-Jul-21 10:31
SeeSharp214-Jul-21 10:31 
GeneralRe: Exception handler Pin
Drugodrf15-Jul-21 6:15
Drugodrf15-Jul-21 6:15 
GeneralRe: Exception handler Pin
Victor Nijegorodov15-Jul-21 9:25
Victor Nijegorodov15-Jul-21 9:25 
GeneralRe: Exception handler Pin
jschell17-Jul-21 9:38
jschell17-Jul-21 9:38 
GeneralRe: Exception handler Pin
Victor Nijegorodov17-Jul-21 9:51
Victor Nijegorodov17-Jul-21 9:51 
GeneralRe: Exception handler Pin
Richard MacCutchan17-Jul-21 21:08
mveRichard MacCutchan17-Jul-21 21:08 
QuestionC++ Pin
Member 152817338-Jul-21 8:52
Member 152817338-Jul-21 8:52 
AnswerRe: C++ Pin
OriginalGriff8-Jul-21 8:56
mveOriginalGriff8-Jul-21 8:56 
Compiling does not mean your code is right! Laugh | :laugh:
Think of the development process as writing an email: compiling successfully means that you wrote the email in the right language - English, rather than German for example - not that the email contained the message you wanted to send.

So now you enter the second stage of development (in reality it's the fourth or fifth, but you'll come to the earlier stages later): Testing and Debugging.

Start by looking at what it does do, and how that differs from what you wanted. This is important, because it give you information as to why it's doing it. For example, if a program is intended to let the user enter a number and it doubles it and prints the answer, then if the input / output was like this:
Input   Expected output    Actual output
  1            2                 1
  2            4                 4
  3            6                 9
  4            8                16
Then it's fairly obvious that the problem is with the bit which doubles it - it's not adding itself to itself, or multiplying it by 2, it's multiplying it by itself and returning the square of the input.
So with that, you can look at the code and it's obvious that it's somewhere here:
C#
int Double(int value)
   {
   return value * value;
   }

Once you have an idea what might be going wrong, start using the debugger to find out why. Put a breakpoint on the first line of the method, and run your app. When it reaches the breakpoint, the debugger will stop, and hand control over to you. You can now run your code line-by-line (called "single stepping") and look at (or even change) variable contents as necessary (heck, you can even change the code and try again if you need to).
Think about what each line in the code should do before you execute it, and compare that to what it actually did when you use the "Step over" button to execute each line in turn. Did it do what you expect? If so, move on to the next line.
If not, why not? How does it differ?
Hopefully, that should help you locate which part of that code has a problem, and what the problem is.
This is a skill, and it's one which is well worth developing as it helps you in the real world as well as in development. And like all skills, it only improves by use!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!

QuestionRe: C++ Pin
David Crow8-Jul-21 12:19
David Crow8-Jul-21 12:19 
AnswerRe: C++ Pin
Richard MacCutchan8-Jul-21 21:10
mveRichard MacCutchan8-Jul-21 21:10 
GeneralRe: C++ Pin
charlieg17-Aug-21 11:38
charlieg17-Aug-21 11:38 
QuestionHelp me to convert all to C++ (stdio.h) Pin
WEI SHEN KOK7-Jul-21 3:47
WEI SHEN KOK7-Jul-21 3:47 
AnswerRe: Help me to convert all to C++ (stdio.h) Pin
Victor Nijegorodov7-Jul-21 4:30
Victor Nijegorodov7-Jul-21 4:30 
AnswerRe: Help me to convert all to C++ (stdio.h) Pin
Dave Kreskowiak7-Jul-21 5:46
mveDave Kreskowiak7-Jul-21 5:46 
AnswerRe: Help me to convert all to C++ (stdio.h) Pin
Maximilien7-Jul-21 9:41
Maximilien7-Jul-21 9:41 
AnswerRe: Help me to convert all to C++ (stdio.h) Pin
Stefan_Lang7-Jul-21 21:16
Stefan_Lang7-Jul-21 21:16 
QuestionBase types and pointer arrays Pin
Richard Andrew x645-Jul-21 18:26
professionalRichard Andrew x645-Jul-21 18:26 
AnswerRe: Base types and pointer arrays Pin
Daniel Pfeffer5-Jul-21 20:56
professionalDaniel Pfeffer5-Jul-21 20:56 
GeneralRe: Base types and pointer arrays Pin
Richard Andrew x646-Jul-21 3:55
professionalRichard Andrew x646-Jul-21 3:55 
AnswerRe: Base types and pointer arrays Pin
Richard MacCutchan5-Jul-21 20:59
mveRichard MacCutchan5-Jul-21 20:59 
GeneralRe: Base types and pointer arrays Pin
Richard Andrew x646-Jul-21 3:56
professionalRichard Andrew x646-Jul-21 3:56 
AnswerRe: Base types and pointer arrays Pin
CPallini5-Jul-21 21:03
mveCPallini5-Jul-21 21:03 
GeneralRe: Base types and pointer arrays Pin
Richard Andrew x646-Jul-21 3:57
professionalRichard Andrew x646-Jul-21 3:57 
AnswerRe: Base types and pointer arrays Pin
jschell17-Jul-21 10:09
jschell17-Jul-21 10:09 
GeneralRe: Base types and pointer arrays Pin
Richard Andrew x6417-Jul-21 13:39
professionalRichard Andrew x6417-Jul-21 13:39 

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.