1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

Yes or No decision problem

Discussion in 'Mac Programming' started by hawkeye10, Feb 3, 2012.

  1. macrumors newbie

    #1
    Hi guys! I'm kinda new to programming and I really need help.

    [​IMG]

    so i keep getting this "Exc_Bad_Access" every time I enter "y"

    Code:
    Would you like to take your BMI using Meters(height) & 
    Kilograms(weight)? (y/n): y
    Current language:  auto; currently minimal
    (gdb) 
    
    I would really appreciate the help guys :D
     
  2. macrumors Pentium

    KnightWRX

    #2
    You're passing a char to scanf. What does scanf expect to receive ? Is a char appropriate ?

    Here, I'll give you a strong hint, the appropriate lines in the man page :

     
  3. macrumors member

    #3
    I'm going to steal from Sesame Street a bit here.

    One of these things is not like the others:

    Code:
    scanf(" %c", ans1);
    scanf("%lf", &Meters);
    scanf("%lf", &Kilograms);
     
  4. macrumors G5

    gnasher729

    #4
    For the future: Go to your project settings, and check what compiler warnings you can turn on. The compiler is able to tell you about the exact kind of mistake that you made.
     
  5. macrumors Pentium

    KnightWRX

    #5
    That's why I always compile with -Wall on the command line. Never ignore a warning!
     
  6. macrumors G5

    gnasher729

    #6
    Any new code of mine uses "warnings = errors", including analyser warnings. So I _cannot_ ignore any warnings. (And there is quite a high percentage of warnings that are actually serious bugs. It's easy to miss a '&' as the OP did. The compiler can find it if you let it).
     
  7. macrumors 604

    chrono1081

    #7
    To the OP's defense I've seen several code sites that are missing what he is missing. He may have been looking off of one of those sites.
     
  8. macrumors Pentium

    KnightWRX

    #8
    Considering I've been dragging my ass on a warning for like 3 months on my current project (Something about Class methods being delegates for instance methods not being kosher), I can't exactly go as far as -Wall -Werror :D.

    The worse part is I've fixed the issue by rewriting my Class methods in one class, I just have to do the other that uses the same semantics now. Pure lazyness.
     

Share This Page