[Info-vax] ChatGPT solved it for me, again...
Simon Clubley
clubley at remove_me.eisner.decus.org-Earth.UFP
Tue Feb 21 08:25:14 EST 2023
On 2023-02-20, Arne Vajhøj <arne at vajhoej.dk> wrote:
>
> As I think everybody has agreed by now then the code
> is safe.
>
Yes. :-)
> I still stand by my original assessment that I would not
> have used strcspn for this. It seems weird to me to
> search through the entire string in a way that can handle
> multiple stop characters when one knows that there is
> only one stop character and really are only interested
> in the last char in the string.
>
This is exactly how I normally do it - look at the last character
only and strip that if needed.
Of course, strlen() still has to search through the string before
it knows the length of it, so you don't save as much time as you
might expect.
>
> I do not blame ChatGPT for not thinking about that. This
> is a very special case.
>
ChatGPT not thinking about some things is how some people have been
able to trick it into doing certain things. :-)
Simon.
--
Simon Clubley, clubley at remove_me.eisner.decus.org-Earth.UFP
Walking destinations on a map are further away than they appear.
More information about the Info-vax
mailing list