Please help - Problem with scanf

Discussion in 'C' started by yoavagami, Jan 1, 2008.

  1. yoavagami

    yoavagami New Member

    Joined:
    Jan 1, 2008
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    I need to write a code that get as an input a double, and if the user puts an "ENTER", it will continue, but the scanf function waits untill the user puts anything exept "ENTER".
    Thank you.
     
  2. b.t.e

    b.t.e New Member

    Joined:
    Jan 1, 2008
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    does the user takes the inputs from a file?
    if so ..

    float num; // double

    scanf("%f",&num);

    while( !EOF ) // !EndOfFile
    {
    scanf("%f",&num);
    }
     
  3. yoavagami

    yoavagami New Member

    Joined:
    Jan 1, 2008
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Its not from a file.. is there some way to exept the "ENTER"? Thanks..
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,352
    Likes Received:
    382
    Trophy Points:
    83
    Then when you want to break?
     
  5. yoavagami

    yoavagami New Member

    Joined:
    Jan 1, 2008
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    I need to get input a double, and if the user puts "ENTER", it will continue (when I do scanf(%lf,&num); it "waits" untill I input something and just after that it will continue..
    (I'm not using files..)
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice