c - No prompt for an integer -


this question has answer here:

i'm using eclipse c/c++ tried out code making pascal's triangle , when run doesn't print "enter number of rows: " until after enter number though printf comes before scanf

int main(void) { int rows, coef = 1, space, i, j; printf("enter number of rows: "); scanf("%d", &rows); printf("\n"); //i added (i = 0; < rows; i++) {     (space = 1; space <= rows - i; space++)         printf("  ");     (j = 0; j <= i; j++) {         if (j == 0 || == 0)             coef = 1;         else             coef = coef * (i - j + 1) / j;         printf("%4d", coef);     }     printf("\n"); } return 0; } 

my question whether there wrong eclipse c/c++ because never had problem on eclipse java when asked input this. how fix this.

nothing wrong tools.

printf default buffers output until newline \n printed.

you can address doing fflush(stdout) after printf not contain \n.

or can turn off line buffering altogether:

setvbuf(stdout, null, _ionbf, 0); 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -