Re: What's the guideline for dealing with unwanted chars in input stream?
- From: "Chuck F. " <cbfalconer@xxxxxxxxx>
- Date: Sat, 31 Dec 2005 08:55:15 -0500
Richard Heathfield wrote:
lovecreatesbeauty said:
.... big snip ... >
19 20 /* remove unwanted chars in input stream here now */ 21 while(getchar() != '\n'); //intended null loop body
This won't work, because it will keep reading and discarding characters up to AND INCLUDING the first non-newline, which is presumably supposed to be data.
Hunh? It will remove chars from the stream, including the '\n'. The fault is that it doesn't check for EOF, which can lead to a fairly long wait.
-- "If you want to post a followup via groups.google.com, don't use the broken "Reply" link at the bottom of the article. Click on "show options" at the top of the article, then click on the "Reply" at the bottom of the article headers." - Keith Thompson More details at: <http://cfaj.freeshell.org/google/> .
- Follow-Ups:
- Re: What's the guideline for dealing with unwanted chars in input stream?
- From: Richard Heathfield
- Re: What's the guideline for dealing with unwanted chars in input stream?
- References:
- What's the guideline for dealing with unwanted chars in input stream?
- From: lovecreatesbeauty
- Re: What's the guideline for dealing with unwanted chars in input stream?
- From: Richard Heathfield
- What's the guideline for dealing with unwanted chars in input stream?
- Prev by Date: Re: Adding the ability to add functions into structures?
- Next by Date: Re: Structure size and binary format
- Previous by thread: Re: What's the guideline for dealing with unwanted chars in input stream?
- Next by thread: Re: What's the guideline for dealing with unwanted chars in input stream?
- Index(es):
Relevant Pages
|