please read this source code and tell me what is wrong

This is a discussion on please read this source code and tell me what is wrong within the Windows Programming forums, part of the Platform Specific Boards category; This is the soruce code for a win32 prog that you enter two numbers and select your operator to go ...

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    4

    Thumbs up please read this source code and tell me what is wrong

    This is the soruce code for a win32 prog that you enter two numbers and select your operator to go between them and then it outputs and answer. It's under 2K zipped and I appreciate anyone who will take the time to read it! Thanks!
    Attached Files Attached Files

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    >please read this source code and tell me what is wrong

    hm... this is your compilers job. It will do it in a minute if you try.
    If you don't get what the errormessage means, come back here and post it.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    4
    Sorry, I should have been more specific. The program compiles fine, but doesn't work "right" ie how I want it to. I am not asking for any source code, just an explanation of what is wrong. Thanks for your time.

  4. #4
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    How does it "not work right"? What are the symptoms?
    1978 Silver Anniversary Corvette

  5. #5
    Registered User
    Join Date
    Nov 2001
    Posts
    4
    It doesn't add/subtract/multiply/divide the numbers when you enter two numbers and click a operator button. It gives out a seemingly random number, not the right answer. Here is the exec file, It not virused or anything.
    Attached Files Attached Files

  6. #6
    Banned maes's Avatar
    Join Date
    Aug 2001
    Posts
    744
    -> make "numone" and "numtwo" static, otherwise they will lose their value.

    ->your use of GetDlgItemInt is wrong
    numone=GetDlgItemInt(hDlg,IDC_NUMONE,NULL,TRUE);

    ->it is better to check also if you change your operation (+,-,*,/)
    Code:
    case IDC_PLUS:
    case IDC_MINUS:
    case IDC_MULTIPLY:
    case IDC_DIVIDE:
    Calculate(hDlg,numone,numtwo);
    break;
    one more thing: in your "Calculate" function, check if numtwo is zero. It is safer. press the '/' button before entering a number in numtwo and see what happens

  7. #7
    Registered User
    Join Date
    Nov 2001
    Posts
    4

    thanks!

    Hey thanks maes, it works right now. I really appreciate it!

  8. #8
    Unregistered
    Guest

    thanks!

    Hey thanks maes, it works right now. I really appreciate it!

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21