The issue is that it just goes straight through the entire program without waiting for user input. I've tried tricking with conditional statements but it just seems to not want to get any user input.

I've crawled the web for about day on this, so if anyone has had a similar experience, please let me know. Im Using X-code and obj-c, im fairly new to it. But Ive been doing C/C++ for a little more then 3 years just to give a little background on my C knowledge.

Replies To: Scanf & X-code 4 issues

Re: Scanf & X-code 4 issues

Posted 18 August 2011 - 11:24 PM

It could be garbage on stdin, or it could be that mac doesn't support the '%i' format string. Not having access to a mac I can't test the second theory. If using '%d' instead doesn't fix your problem, try seeing what's on stdin instead of reading to an int.

Re: Scanf & X-code 4 issues

Posted 19 August 2011 - 06:46 AM

GWatt, on 19 August 2011 - 12:24 AM, said:

It could be garbage on stdin, or it could be that mac doesn't support the '%i' format string. Not having access to a mac I can't test the second theory. If using '%d' instead doesn't fix your problem, try seeing what's on stdin instead of reading to an int.

Re: Scanf & X-code 4 issues

Posted 19 August 2011 - 07:19 AM

So I was able to sit down at a mac computer today, but I am unable to replicate your bug. I have a couple suggestions.
1) Recompile your program with all of the warning options on. Assuming you compiled from the terminal, your command should look something like this:gcc -o triangle triangle.m -framework Foundation -W -Wall -Wextra -pedantic -Werror

2) Write a very simple program using scanf to see if it's more than just that other program. If more things are experiencing this strange behavior something else (I don't know what) is probably the cause.

Re: Scanf & X-code 4 issues

Posted 19 August 2011 - 08:00 AM

GWatt, on 19 August 2011 - 08:19 AM, said:

So I was able to sit down at a mac computer today, but I am unable to replicate your bug. I have a couple suggestions.
1) Recompile your program with all of the warning options on. Assuming you compiled from the terminal, your command should look something like this:gcc -o triangle triangle.m -framework Foundation -W -Wall -Wextra -pedantic -Werror

2) Write a very simple program using scanf to see if it's more than just that other program. If more things are experiencing this strange behavior something else (I don't know what) is probably the cause.

ok I can try but im not sure how to do a terminal mode in X-code4. Ill look into it.

What im investigating now is if I need to #include/import something. And for a moment I thought I need #import <stdio>
But that did not change anything *Sigh*

But Ill try to get a terminal program going, as far as I know the debugger(gdb) is always on in Xcode.
Again I appreciate you taking time to bounce ideas off with me on this.

Re: Scanf & X-code 4 issues

Mac OS comes with a terminal emulator. It's called "Terminal." You can quickly launch it by pressing command+space and searching for "terminal"

It works in Terminal, I'm convinced there's something about X-Code4 that i don't understand.
Now I know where the problem lies now.
Thanks for your help, If you have additional input on how to debug this issue in X-code4 I'm all ears
~Syn