You are viewing a single thread.
View all comments View context
2 points
*

Data after dst+n is unchanged.

Sure but that means the part before that is garbage because you have a null terminated string without terminator.

Or at least that’s how I see it. If your intention isn’t to start and end with a null-terminated string you should be using memcpy. Let us not talk about situations where CHAR_BIT != 8 that’s not POSIX anyway.

Even better, just avoid doing string manipulation in C.

permalink
report
parent
reply
1 point

Let us not talk about situations where CHAR_BIT != 8 that’s not POSIX anyway.

Yeah, let’s not talk about 20-bit one’s complement ints.

permalink
report
parent
reply

Programmer Humor

!programmer_humor@programming.dev

Create post

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics

Community stats

  • 7.7K

    Monthly active users

  • 978

    Posts

  • 38K

    Comments