Author: Stan Eisenstat
Subject: Re: [Cs223] Trailing Newlines
Date: Sunday, 29 Mar 2020, 16:12:31
> Message Posted By: Unknown
>
> I am a bit confused of why we need to remove trailing newlines ("removes
> their trailing newlines if any"). Could I possibly get an example of when
> it becomes a problem when I do not because the public cases are working
> for me.
As I posted earlier:
Date: 23 Mar 2020 10:22:33 -0400 (Mon)
Subject: Re: [Cs223] remove trailing newlines
> 3. What is the point of removing trailing newlines? Can't we just
> process each line with the last character as a newline?
Hint: '\t' < '\n', but for sorting purposes you want
"a" < "a\tb".
=====
As I posted earlier:
> Also since we do have to remove trailing newlines, is there a c function
> that assists in doing this for us from getline?
Date: 15 Mar 2020 13:21:37 -0400 (Sun)
Subject: Re: [Cs223] Removing trailing newlines from input from file(s)
> Message Posted By: Unknown
>
> When using getline() to get lines from a file, is there an easier way to
> remove trailing newlines than writing a function that traverses the line
> buffer after calling getline() until it finds a newline and then
> reallocating the line buffer and removing the newline if it finds one?
See strrchr() (or "man strrchr" for details).
--Stan-
PREV
INDEX
NEXT