Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7885917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:11:29+00:00 2026-06-03T05:11:29+00:00

I need to receive numbers until I press enter, I’ve tried to compare the

  • 0

I need to receive numbers until I press enter, I’ve tried to compare the returned value of the scanf with EOF but it keeps asking me to enter more numbers(infinite loop) :

int fail=0, late=0, avg=0, i=0, last=0, current, permission, difference;
while(scanf(" %d", &current) != EOF)
{
    permission = (current < last);
    difference = ((last - current) >= 30);
    fail += difference*permission;
    late += permission;
    avg += (last - current)*(permission);
    last = last*(permission) + current*(!permission);
}

Any suggestions.

thanx

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T05:11:30+00:00Added an answer on June 3, 2026 at 5:11 am

    Well, the scanf specification says that it will read and ignore any whitespace characters. Also, the specification says that EOF is returned only in case of an input failure before any data could be successfully read. You can read it by yourself here.

    I would suggest using other reading functions as mentioned in other answers. Still, if you have to live and die with that scanf loop, perhaps you can add inside, at the bottom, the following code:

    if (getchar() == '\n') break;
    

    It should work if your input are only numbers and it’s just a way to make it work around.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to receive a GTK+ focus in event on a Terminal (VTE), but
Given 'N' and L(number of lines), I need to receive the first N numbers
I need to receive an editable format (xml or json or otherwise) the result
I am using the Add-on builder and I need to receive binary data (image).
I am new to ruby. I need to receive password as an input through
i need to send and receive data to/from a microcontroller using java using usb
I need the equivalent of git post-receive hook in Mercurial so I can notify
Ok i need to use json on my iOS application to send/receive data to/from
In order to send and receive encrypted messages from/to the iPhone I need to
I am writing a small program that sends and receive multicast packets.I need to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.