0
Good night. I have the program below that asks the user to enter 2 numbers and then present them. Code Blocks is working correctly, but when running in Eclipse or Netbeans, the system is waiting for the numbers to be entered without the messages being shown on the printf. Does anyone know how to solve?
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char** argv) {
int num1, num2;
printf ("Digite o primeiro numero: ");
scanf("%d", &num1);
printf ("Digite o segundo numero: ");
scanf("%d", &num2);
printf ("Os números diigitados foram %d e %d.", num1, num2);
return 0;
}
Console result:
5
5
Digite o primeiro numero: Digite o segundo numero: Os números digitados
foram 5 e 5.
I ran your program and nothing went wrong, see.
– gato
Yes, in Code Blocks it works normally but in Eclipse and Netbeans it doesn’t. It must be some problem with IDE configuration.
– Rogerio Santos
What seems to have happened is that in these Ides he is following the standard bufferization of
stdout
: print when having a\n
or reach the end of the program. If you break lines (or change the bufferization to byte to byte) you should get a better result. There are two ways to test this: (a) by putting\n
in eachprintf
or (b) keeping the prints the way they are, only going tostderr
– Jefferson Quesado
@Even though the n remains with the same problem, the console only displays the messages in the printf after typing the numbers. I couldn’t use stderr, you can show me?
– Rogerio Santos
fprintf(stderr, "o resto normalmente como printf");
– Jefferson Quesado
I typed this way but showed no error. The problem continued.
– Rogerio Santos