Reputation: 633
I am trying to run c in xcode 6,however I run the ⌘R it shows build Succeeded but nothing in console,but I can run it in ubuntu Linux's gcc,here is my c code in ubuntu Linux
#include <stdio.h>
int main()
{
int a[100],i,j,t,n;
scanf("%d",&n);
for(i=1;i<=n;i++)
scanf("%d",&a[i]);
for(i=1;i<=n-1;i++)
{
for(j=1;j<=n-i;j++)
{
if(a[j]<a[j+1])
{ t=a[j]; a[j]=a[j+1]; a[j+1]=t; }
}
}
for(i=1;i<=n;i++)
printf("%d ",a[i]);
getchar();getchar();
return 0;
}
when I run it in gcc it's ok,
ubuntu#vi ac9.c
ubuntu#gcc -o ac9 ac9.c
ubuntu#./ac9
the file name is ac9.c
but move it to mac's xcode ,I run the ⌘R it shows build Succeeded but nothing in console, and here is my code in xcode 6.4
Upvotes: 0
Views: 189
Reputation: 172
From Xcode not showing anything in console with C++,
Your image doesn't show that you ran the program, only that you built it. Look at the Log Navigator (the last one, ⌘7) and see if there are any logs for 'Debug one' after 'Build one'. To run the program use Product > Run or ⌘R.
Upvotes: 0
Reputation: 108978
You probably need to signal to the Operating System to dump what is in the output buffer to the screen before the calls to getchar()
.
The easiest way to do that is to print a newline.
// ...
// print a newline; force OS to dump output buffer
printf("\n"); // or puts("");
getchar(); getchar();
// ...
One other way is to call fflush()
// ...
// force OS to dump output buffer
fflush(stdout);
getchar(); getchar();
// ...
Upvotes: 1