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

Obviously strcpy is dangerous, that's why I copy all my strings by hand with:

  while(*dest++ = *src++);


I really hope this was sarcasm. But if not...

There's nothing here to prevent a buffer overrun. If your src doesn't end in 0, or your dest is too small, you'll be reading memory you shouldn't and/or obliterating memory past your dest buffer. Your method is pretty much on par with an inlined strcpy.


That's the joke


The method is exactly an inlined strcpy.


I don't always copy strings, but when I d8$#@C11&C^C^CSegmentation Fault




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

Search: