Re: removing newline character from the buffer read by fgets



junky_fellow@xxxxxxxxxxx said:

<snip>

thanks everyone for your help. In fact, I don't want to use strlen() or
strchr()
(for efficiency reasons) to remove the newline character.
Based of Richard's suggestion, I tried to write my own version of
fgets()
that will not put newline character to the input buffer passed.
I am sure, the people here will find lots of problems in my code. All
comments
are welcome.

The principal objection I have to your code is that it fails to provide a
way to distinguish between a line that has been read completely and a line
that has been read only partially because of insufficient space in the
buffer.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
.



Relevant Pages

  • Re: [C] Problem with flushing stdin
    ... Jamie wrote: ... > It appears that a newline character is being passed upon returning to ... welcome to clc: http://www.ungerhu.com/jxh/clc.welcome.txt ...
    (alt.comp.lang.learn.c-cpp)
  • Re: array modification
    ... In Perl, "\n" is not linefeed, it is the newline character. ... translates to the proper sequence of characters on each operating ... system, so "\r\n" on a Win32 system is actually three bytes: ...
    (perl.beginners)
  • Re: nextline statement in write function
    ... > a newline character in the statment). ... and there shouldn't be any problem writing a newline to any of the ... standard streams or stream buffers. ...
    (comp.lang.cpp)