Problem with eclipse and a simple c program

L

lionelgreenstreet

I have some problems when this simple program run with eclipse:

#include <stdio.h>
#include <stdlib.h>



int main()
{
int number;
printf("Enter a number\n");
scanf("%d", &number);
printf("You entered %d", number);
return 0;
}

In run mode on consolle nothing appear, "enter a number" appears only
after the inserction of a number and not before. Why?
Thanks
 
J

jacob navia

I have some problems when this simple program run with eclipse:

#include <stdio.h>
#include <stdlib.h>



int main()
{
int number;
printf("Enter a number\n");
scanf("%d", &number);
printf("You entered %d", number);
return 0;
}

In run mode on consolle nothing appear, "enter a number" appears only
after the inserction of a number and not before. Why?
Thanks

When I run this from a console it works correctly here
(windows vista 64/ lcc-win compiler)

Maybe in some systems you have to write
fflush(stdout);
after the printf statement. Try that.
 
E

Eric Sosman

I have some problems when this simple program run with eclipse:

#include <stdio.h>
#include <stdlib.h>



int main()
{
int number;
printf("Enter a number\n");
scanf("%d", &number);
printf("You entered %d", number);
return 0;
}

In run mode on consolle nothing appear, "enter a number" appears only
after the inserction of a number and not before. Why?

This is Question 12.4 in the comp.lang.c Frequently
Asked Questions (FAQ) list at <http://www.c-faq.com/>.
 
P

pete

I have some problems when this simple program run with eclipse:

#include <stdio.h>
#include <stdlib.h>

int main()
{
int number;
printf("Enter a number\n");
scanf("%d", &number);
printf("You entered %d", number);
printf("You entered %d\n", number);
return 0;
}

In run mode on consolle nothing appear, "enter a number" appears only
after the inserction of a number and not before. Why?

The last text line of a text stream may need to be newline terminated.
For portable C programming,
the last text line of a text stream should be newline terminated.

N869
7.19.2 Streams

[#2] A text stream is an ordered sequence of characters
composed into lines, each line consisting of zero or more
characters plus a terminating new-line character. Whether
the last line requires a terminating new-line character is
implementation-defined.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top