Re: equivalent of chomp in perl
- From: Jordan Abel <random@xxxxxxxxxxxxx>
- Date: 3 Nov 2006 20:10:49 GMT
2006-11-03 <454B886C.E59D48F1@xxxxxxxxx>,
CBFalconer wrote:
Keith Thompson wrote:
CBFalconer <cbfalconer@xxxxxxxxx> writes:
lnatz wrote:
Is there an equivalent to the perl command chomp in C? And if
there is no exact equivalent command, how would I go about
removing the "\n" at the end of a stdin?
int flushln(FILE *f) {
int ch;
while (('\n' != (ch = getc(f))) && (EOF != ch)) continue;
return ch;
}
That's a useful function, but it's doesn't bear any particular
resemblance to Perl's chomp function.
Probably so, but I suspect it is the answer to the OPs real
question, which was not well defined.
Are you sure? chomp is used for a specific purpose, which is removing
the newline from a whole line read from input. fgets() also leaves the
newline on the input line. The function above is more useful for people
who think they want to fflush(stdin) [after, say, a scanf] - but the OP
didn't say anything like that.
.
- Follow-Ups:
- Re: equivalent of chomp in perl
- From: james of tucson
- Re: equivalent of chomp in perl
- From: James McGill
- Re: equivalent of chomp in perl
- From: Walter Roberson
- Re: equivalent of chomp in perl
- References:
- equivalent of chomp in perl
- From: lnatz
- Re: equivalent of chomp in perl
- From: CBFalconer
- Re: equivalent of chomp in perl
- From: Keith Thompson
- Re: equivalent of chomp in perl
- From: CBFalconer
- equivalent of chomp in perl
- Prev by Date: Re: bit fields pointers?
- Next by Date: Re: [OT] (was: Re: Question about C Functions)
- Previous by thread: Re: equivalent of chomp in perl
- Next by thread: Re: equivalent of chomp in perl
- Index(es):
Relevant Pages
|
|