自从更新到 Xcode 4.5 后,我遇到了这个问题。
我在控制台框中输入了 4555
,但控制台框中只显示了 4
。
我尝试了不同的输入参数,例如%d
、%f
、%c
和%s
,都有同样的问题。
我不明白。如何解决?
我的源码是
#include <stdio.h>
int main()
{
int input;
// insert code here...
printf("Hello, World!\n");
printf("Please Enter Number : ");
scanf("%d",&input);
getchar();
printf("Input is : %d",input);
return 0;
}
控制台框显示:
>Hello, World!
>Please Enter Number : 4
>Input is : 4555
最佳答案
看来这是Xcode 4.5的一个bug。见:
There's a discussion of this issue on Apple's paid developer forums. It's a bug in Xcode 4.5. Apple's engineers are looking into the issue, but there's no fix yet.
There are two workarounds. The first workaround is to run your command-line app from the Terminal. In the Xcode project navigator select your executable from the Products folder. Right-click and choose Show in Finder. Double-click the executable in the Finder to launch it in the Terminal.
The second workaround is to install Xcode 4.4. Choose Xcode > Open Developer Tool > More Developer Tools to access Apple's developer downloads site.
Yes, this is a confirmed regression from 4.4, and we're tracking it internally. It is really unfortunate that this slipped in, but we'll get it fixed ASAP.
关于c - Xcode 4.5 字符未显示在控制台框中,使用 C 语言中的 scanf(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12635860/