20 Comments

User's avatar
Paul Kennedy's avatar

I believe a likely explanation for why the interviewer wanted you to write it that way is because that is considered the "idiomatic" way.

If you have a copy of "The C Programming Language" 2nd edition handy, flip to page 106 (or look up strcpy in the index). It says "Although this may seem cryptic at first, the notational convenience is considerable, and the idiom should be mastered, because you will see it frequently in C programs."

Whether it is the most readable is, of course, debatable, but hopes of better compiler output may not have been the reason the interviewer wanted you to write it this way.

Expand full comment
Yakvi's avatar

Maybe the interviewer wanted to check whether the potential intern knew about pointer arithmetic? That you can, in fact, do something like *From++

That, and of course terseness for terseness's sake.

Expand full comment
18 more comments...

No posts