logoalt Hacker News

CamperBob2yesterday at 10:33 PM4 repliesview on HN

    void CopyString(char *From, char *To)
    {
        /* Fill this in */
    }
The only correct answer to this interview question is "No."

Replies

anitiltoday at 12:15 AM

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.

show 1 reply
HarHarVeryFunnytoday at 12:44 AM

/* YOLO */

while (*to++ = *from++) ;

show 2 replies
ggambettatoday at 6:45 AM

Thought the same. Reckless today, literally standard back then.

sgerenseryesterday at 10:50 PM

Hey, in 2026 strcpy is still part of the C standard library (much to the chagrin of anyone security conscious).

show 1 reply