Hacker News new | past | comments | ask | show | jobs | submit login

The 'strn' functions are wrong, stop using them.

https://randomascii.wordpress.com/2013/04/03/stop-using-strn...




This solution uses templates, which are C++, not C

But if you're using C++, use C++ strings, you don't need strcpy

There's strlcpy mentioned there, which seems a better C solution


strncpy is fine if you wrap it with a length error check or explicit 0 terminator.




Join us for AI Startup School this June 16-17 in San Francisco!

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

Search: