Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

hawkeye10

macrumors newbie
Original poster
Feb 3, 2012
1
0
Hi guys! I'm kinda new to programming and I really need help.

ScreenShot2012-02-03at53748PM.png


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
 
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 :

Each successive pointer argument must correspond properly with each suc-
cessive conversion specifier (but see the * conversion below). All con-
versions are introduced by the % (percent sign) character.
 
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);
 
I would really appreciate the help guys :D

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.
 
That's why I always compile with -Wall on the command line. Never ignore a warning!

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).
 
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.
 
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).

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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.