I have got this problem since updated to Xcode 4.5.
I typed 4555
in console box but it show only 4
in console box.
I tried different input parameters such as %d
, %f
, %c
and %s
, all have the same problem.
I don't get it. How to fix it?
My source code is
#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;
}
and console box shows:
>Hello, World!
>Please Enter Number : 4
>Input is : 4555
It seems that this is a bug of Xcode 4.5. See:
- xCode 4.5 console input - Apple Support Communities
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.
- Re: standard input from console not working in Xcode 4.5
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.