News for hackers. Stuff that matters.
Re:Everything I wish I knew when learning C by mtlmtlmtlmtl on Monday November 28, 2022 @09:40AM (#33774122)
>sizeof dst

Note that this only works if dst is a stack allocated(in the same function) array and not a char *

Re:Everything I wish I knew when learning C by unwind on Monday November 28, 2022 @12:05PM (#33776152)
Yes it should be read as a placeholder for whatever you need to do.

Could be an array inside a struct too for instance, that is quite common.

Re:Everything I wish I knew when learning C by sedatk on Monday November 28, 2022 @04:03PM (#33779596)
> and always remember that "%s" part. Never put src there, of course

> Note that this only works if dst is a stack allocated array

Even this "ideal" solution is full of pitfalls. The state of memory safety is so sad in the world of C.