Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


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


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.


Equivalent of a strcpy() there's no bounds checking.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: