News for hackers. Stuff that matters.
Re:C Strings and my slow descent to madness by kovac on Thursday April 06, 2023 @08:12PM (#35476364)
Could you explain why this line should be discouraged? I'm a beginner in C, so I really don't know. That's why I'm asking.
Re:C Strings and my slow descent to madness by fatcow on Thursday April 06, 2023 @10:24PM (#35477266)
while (t++ = s++) ;

You're assigning a char to another, relying on the return value being 0 to detect end of string.

You're performing the copy while also increasing the pointers with ++ in the same expression.

You're using the cryptic ; empty statement to signify nop, thereby confusing newbies.

Etc

Re:C Strings and my slow descent to madness by commandersaki on Friday April 07, 2023 @01:27AM (#35478353)
Equivalent of a strcpy() there's no bounds checking.
Re:C Strings and my slow descent to madness by tragomaskhalos on Friday April 07, 2023 @04:39AM (#35479571)
Another reason, in addition to other replies and separate from safety concerns, is that strcpy, memcpy etc are nowadays usually implemented via more efficient compiler intrinsics rather than an explicit loop.