4 ms·
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.
by kovac 4y ago
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.
- fatcow 4y agowhile (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
- commandersaki 4y agoEquivalent of a strcpy() there's no bounds checking.
- tragomaskhalos 4y agoAnother 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.