943,771 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 1452
  • C RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Jan 4th, 2009
0

Re: Please help me fix these errors

*Sigh* Okay, but could we please get back to trying to work this out. I'm at a total lose. I really appreciate the help that has been given and I just need to ask you all to show me a bit more kindness so that I can get this thing working.
Reputation Points: 10
Solved Threads: 0
Light Poster
RenFromPenn is offline Offline
40 posts
since Dec 2008
Jan 4th, 2009
0

Re: Please help me fix these errors

>I just need to ask you all to show me a bit more kindness so that I can get this thing working.

Kindness is not what you need nor will it get that thing working.
What you need is to understand how scanf() works.

scanf() always leave behind the ENTER key, when you press ENTER/RETURN. Which will be read by the next call.
If you insist in using it, then you need to accommodate that behavior.

A possible solution would be to declare another "waste key char" and using in conjunction with the first format , since you know you'll have to press enter to summit data.
char enter_key;
scanf("%d%c", &num, &enter_key);
Of course, that will not prevent the user from entering unexpected input and screwing it. That's for the best scenario.
Aia
Reputation Points: 2224
Solved Threads: 218
Nearly a Posting Maven
Aia is offline Offline
2,304 posts
since Dec 2006
Jan 4th, 2009
0

Re: Please help me fix these errors

I don't insist upon using scanf. If you have a better suggest, then I am perfectly happy to hear it.

Trying you suggestion did cause each line to display. I was able to enter a number, a character, but not the floating point. When The line came up it already had a value there. The program also didn't assemlbe everything and print it as it's supposed to.

--

Okay, this time I tried it and the floating point line didn't have a value already. It, however, wouldn't let me type anything there.
Last edited by RenFromPenn; Jan 4th, 2009 at 5:15 pm.
Reputation Points: 10
Solved Threads: 0
Light Poster
RenFromPenn is offline Offline
40 posts
since Dec 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Need Help..!!
Next Thread in C Forum Timeline: any one have idea about compiler control directives





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC