4 ms·
void CopyString(char *From, char *To) { /* Fill this in */ } The only correct answer to this interview question is "No."
by CamperBob2 5mo ago
void CopyString(char *From, char *To)
{
/* Fill this in */
}
The only correct answer to this interview question is "No."
- sgerenser 5mo agoHey, in 2026 strcpy is still part of the C standard library (much to the chagrin of anyone security conscious).
- userbinator 5mo agoThe key point (which I believe static analysers these days can easily check for) is to check the sizes of the source and destination.
- anitil 5mo agoWell in an interview I guess something like "Of course we shouldn't allow C-strings in general outside of syscalls and argv, but for the purpose of the exercise...." And now you've shown that you know what you're talking about and that you won't be difficult to work with.
- TZubiri 5mo agoI don't think it was clear in 1994 that not passing the size of a string was a sin
- anitil 5mo agoOh 100%, I was responding to the parent who's response was 'No'. Even if you have 100% ban on strcpy and z-strings you're forced to use them in certain cases (like argv), and I was pointing out that sometimes we engage with certain conceits in a job interview, and by refusing to engage with it you're giving out a signal that you'll be difficult to work with
- HarHarVeryFunny 5mo ago/* YOLO */ while (*to++ = *from++) ;
- 0x1ceb00da 5mo agoSyntax error: variable "to" not found
- HarHarVeryFunny 5mo agoUpper case is for compile-time constants. I couldn't make myself do it.
- userbinator 5mo agoI see someone has read K&R.
- ggambetta 5mo agoThought the same. Reckless today, literally standard back then.