Comment by CamperBob2
17 hours ago
void CopyString(char *From, char *To)
{
/* Fill this in */
}
The only correct answer to this interview question is "No."
17 hours ago
void CopyString(char *From, char *To)
{
/* Fill this in */
}
The only correct answer to this interview question is "No."
Well 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.
I don't think it was clear in 1994 that not passing the size of a string was a sin
/* YOLO */
while (*to++ = *from++) ;
I see someone has read K&R.
Syntax error: variable "to" not found
Upper case is for compile-time constants. I couldn't make myself do it.
Thought the same. Reckless today, literally standard back then.
Hey, in 2026 strcpy is still part of the C standard library (much to the chagrin of anyone security conscious).
The key point (which I believe static analysers these days can easily check for) is to check the sizes of the source and destination.