Whenever I run my code under the Eclipse IDE it first requires me to enter the input, and only then shows the output (Although when I run it through cmd it works fine).
For example: for this code:
Code:
#include <stdio.h>
int main()
{
printf("Hello World!\nEnter a number: ");
int x = 0;
scanf("%d",&x);
printf("You've entered %d", x);
return 0;
}
I see an empty console every time i run it, and only after I enter a number (let's say 99), I see:
99
//that's actually part of the standard input, and not part of the standard output
Hello World!
Enter a number: You've entered 99
whether the expected result should be
Hello World!
Enter a number:
and only after I enter 99, i would see:
99
//again - this is not the issue here, but just so you won't get confused: this is supposed to be my input
You've entered 99
Old post was:
Title: inline declarations in Visual Studio 2010
Content:
hi,
I usually don't use visual studio for programming in c, but I've decided to try it.
I've noticed that for some reason i can't use inline declaration in Visual studio (although as far as I know it is perfectly legal in c99). For example, when writing this simple program:
Code:
#include <stdio.h>
int main()
{
printf("Enter an integer: ");
int x = 0;
scanf("%d", &x);
printf("you've entered: %d", x);
return 0;
}
I get
error C2143: syntax error : missing ';' before type
and
error C2065: 'x' : undeclared identifier
Of course, switching the first two lines in the main function solves this problem.
Since I find Eclipse inconvenient (please excuse me dear Eclipse fans), and I'm used to using VS for programming .Net applications, I'd rather keep using it.
How can I enable inline declaration in Visual Studio 2010?
Thanks in advance!