E
E
EldaarLiis2018-11-08 21:52:40
Eclipse
EldaarLiis, 2018-11-08 21:52:40

How can I run a program in Eclipse so that it doesn't require input before running the code directly?

I just started learning to program in Eclipse and I don’t know at all why the console (wired) requires data input before running the code itself. Although I may have messed up in setting up Eclipse itself, I ask for help, because I don’t understand this at all.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
res2001, 2018-11-09
@res2001

These are manifestations of buffered output. Those. in fact, printf has already been executed before the input, but it has not yet been displayed on the screen.
Insert fflush(stdin) between printf and scanf.

E
EldaarLiis, 2018-11-11
@EldaarLiis

Based on what I understand, the problem is in the settings of the eclipse itself. The console works as it should:
But with the same code (except for getch(), which kills eclipse for some reason), eclipse doesn't want to work properly:
Program code respectively:

The code
#include
#include
#include
int main ()
{float a,b,c,p,s;
printf(" a="); scanf("%f",&a);
printf(" b="); scanf("%f",&b);
printf(" c="); scanf("%f",&c);
p=(a+b+c)/2;
s=sqrt(p*(p-a)*(p-b)*(p-c));
printf("\n Triangle area=%.3f", s) ;
//getch();
return 0;
}

I hope someone will tell you where to look in the settings?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question