Problem with eclipse and a simple c program

Discussion in 'C Programming' started by lionelgreenstreet@gmail.com, Dec 12, 2007.

  1. Guest

    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
     
    , Dec 12, 2007
    #1
    1. Advertising

  2. jacob navia Guest

    wrote:
    > 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.


    --
    jacob navia
    jacob at jacob point remcomp point fr
    logiciels/informatique
    http://www.cs.virginia.edu/~lcc-win32
     
    jacob navia, Dec 12, 2007
    #2
    1. Advertising

  3. Eric Sosman Guest

    wrote:
    > 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/>.

    --
    Eric Sosman
    lid
     
    Eric Sosman, Dec 12, 2007
    #3
  4. pete Guest

    wrote:
    >
    > 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.

    --
    pete
     
    pete, Dec 12, 2007
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    7
    Views:
    649
    Stig Brautaset
    Jul 23, 2003
  2. Replies:
    10
    Views:
    560
    Dennis Lee Bieber
    Aug 15, 2006
  3. Replies:
    14
    Views:
    542
    Karl Heinz Buchegger
    Nov 2, 2005
  4. Replies:
    1
    Views:
    602
    GArlington
    Aug 31, 2007
  5. RichardOnRails
    Replies:
    3
    Views:
    132
    RichardOnRails
    Jul 21, 2008
Loading...

Share This Page