We have reduced support for legacy browsers.

What does this mean for me? You will always be able to play your favorite games on Kongregate. However, certain site features may suddenly stop working and leave you with a severely degraded experience.

What should I do? We strongly urge all our users to upgrade to modern browsers for a better experience and improved security.

Objective C help

So I tried making a calculator… but it doesn’t seem to work. I have NO idea why. The way it’s acting, is it let’s me input the first number (a float), then skips OVER the operator (a char), and then lets me input the second number (another float), which results in an error… I think the problem is something with me using scanf(), maybe the fact that the operator is a char as well? It’s a 6 function calculator that i made mainly to test switch, scanf(), and to make a relatively basic program. I’m just wondering if someone can tell me whats wrong… Thanks a lot if you can help!!!
PS. What’s the difference from printf("") and NSLog(@"")? All i noticed was the time stamp, which was kind of bothering me when i was testing this so i changed to printf("").
**Posting the code didn’t work with formatting and such… so use this link to see it [http://snipt.org/zNgj5](http://snipt.org/zNgj5)**

The program successfully builds. basically it SHOULD work like this…
It’ll say,
Welcome to this basic calculator! Choose your numbers and operations
NOTE – Accepts +, -, \*, /, ^, and r for root (index in front, radicand after):
Pick first number…
(then you pick a number)
Operator…
(for some reason this is written, but it skips the step for me to input the operator. this causes the problem)
Another number….
(It let’s me input this too)
Then you should get the answer. but because the operator isn’t inputted, I get an “ERROR” message. I actually just realized it’s because in the switch, i made the default send the message “ERROR” haha. So there’s no actually crash in the program. It just seems to skip the step to let me input the operator. because operator is the only char variable, I wonder if that has to do with it…?

From [this page on StackOverflow](http://stackoverflow.com/questions/1669821/scanf-skips-every-other-while-loop-in-c) (I vaguely recalled something about this, but I haven’t touched C in roughly 20 years):
When you read keyboard input with scanf(), the input is read after enter is pressed but the newline generated by the enter key is not consumed by the call to scanf(). That means the next time you read from standard input there will be a newline waiting for you (which will make the next scanf() call return instantly with no data).
To avoid this, you can modify your code to something like:
scanf(“%c%\*c”, &currentGuess);
The %\*c matches a single character, but the asterisk indicates that the character will not be stored anywhere. This has the effect of consuming the newline character generated by the enter key so that the next time you call scanf() you are starting with an empty input buffer.
Caveat: If the user presses two keys and then presses enter, scanf() will return the first keystroke, eat the second, and leave the newline for the next input call. Quirks like this are one reason why scanf() and friends are avoided by many programmers.

You want a really easy way to get your programme to work? Just copy the scanf statement for the char and paste it again underneath. The linefeed will be consumed by the first char scanf, and then your input will go into the second, overwriting the value in the variable will the intended value.
As to an actual answer to your question, I don’t know. As I said, I haven’t touched it in 20 years, so I’d have to look up the answer, which you could do just as easily (and should do, since it is your project).
Addition:
From what I recall, it was an issue of different systems behaving differently: Some would send CR/LF pairs for Enter, others would only return CR. So the scanf would actually consume the CR, but leave the LF (if any). I believe this is why scanf for other values appears unaffected.

Thank you! The program is working now… for the most part. I turned it into a loop with two paths basically. you can keep doing computations with the answer, or you can clear everything and start over with a switch of ‘\_’ which should set the result back to 0, and skip a few lines to mimic clearing the page. for some reason, this ends up turning into some kind of endless loop…. any ideas?
here’s the current code:
[http://snipt.org/zOr4](http://snipt.org/zOr4)

> *Originally posted by **[0ii0](/forums/4/topics/324268?page=1#posts-6821271):***
>
> So im gonna guess that means goto is bad…………..
Yes.
If people try to talk you into believing there’s something good in it, it’s like pretending that the raptor’s ignorance whether you’re still alive while ripping your body apart is a welcome extension of your lifetime.

[There](http://www.drdobbs.com/jvm/programming-with-reason-why-is-goto-bad/228200966) [are](http://forum.codecall.net/topic/53691-why-is-goto-so-bad/) [already](http://stackoverflow.com/questions/2949420/why-using-goto-is-bad-programming) [many](http://forums.devshed.com/beginner-programming-16/why-is-goto-a-bad-programming-practice-790131.html) [answers](http://cboard.cprogramming.com/cplusplus-programming/96479-why-goto-bad.html) [online.](https://www.allegro.cc/forums/thread/589282)
Why don’t you use [Google](http://www.google.com/) next time you have a common question that [already has a very long history.](http://david.tribble.com/text/goto.html)
(I found **all of those links** simply by typing “Why is goto bad?” in Google. It took _less than a second!_)

> *Originally posted by **[0ii0](/forums/4/topics/324268?page=1#posts-6821632):***
>
> Why exactly is it bad? cause it seems very convenient in many respects….
I cannot see any convenience in being devoured by a raptor.
Before this becomes entirely off topic, please tell us if fpurge solved your problem.