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

I don't know the answer of this question. I could do a guestimate on how such thing would work, but I've never coded c/c++ extensively. Am I useless now? I don't really see how this proves someone has basic knowledge about programming. However I could be wrong and this is a function that c/c++ programmers write on a daily base and is indeed a good indicator if someone ever ran a c++ compiler.



It's not in itself something a C programmer would ever really find themself doing, but as an algorithmic question it's fine - it's testing knowledge of looping, radices, strings etc. In C, you normally have to output the string in reverse and then reverse it, so you need to be aware of that. It's also a problem that's quite easy to explain (programmers are familiar with numbers and strings), but due to it's library availability, most people won't have actually written it themselves so it's not just a case of having done it before.

Coincidentally, I was asked this exact question in a phone interview this week. I didn't have to give exact code, I just walked through the principal of it (loop for each digit, dividing by the radix each time using the leftover specify the character (can be a lookup in an array), possible to use bit shifting in base 2/8/16 situations).


Well, I've written that a handful of times, but those were back when I was an embarrassingly bad programmer. Nowadays, I just use one of the various library functions to do it -- if you count C++, there are somewhere near half a dozen ways. It's a task I perform a lot, but the libraries have it covered.

The very same is true for "sort a linked-list", though, and that seems to be a popular one. This type of question isn't normally asked because they actually expect you to do it, but because if you don't know some specific things, the question will expose that.




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

Search: