Re: Really **wonderful** website for C interview questions!!!!!




Richard Bos wrote:
> rajanarayan2005@xxxxxxxxx wrote:
>
> > I just found the BEST and the MOST comprehensive
> > website for C related questions and their answers. It
> > has a VERY, VERY, VERY good collection of the MOST
> > FREQUENTLY ASKED interview questions.
>
> Caveat Lector. I just looked at five of the questions on that page, and
> of those, four of the answers cause undefined behaviour, don't work as
> advertised, or are otherwise inferior. While it's perfectly possible
> that invoking UB in your interview will actually be to your advantage if
> you're trying to get a job with, say, Microsoft or IBM, you wouldn't get
> past my desk if you tried them on me.
>
> Richard

On the same note: have a look at the strlen() function they have (at
the
risk of generating even more revenue for the owner of this page,
but we have done him a lot of good already, so...)
/* code on their site */
int strlen(char *string)
{
char *p=string;

while(*p!='\0')
p++;

return(p-s);
}
and check with (as it is somewhat closer to, the signature part)
/* code from K&R, a not-so-old version */
int strlen(char *s)
{
int n;

for (n = 0; *s != '\0', s++)
n++;
return n;
}
as well as the signature of what we have on most systems ...
size_t strlen(const char *s).

This might just tempt you all the more to stay away!

Regards,
Suman.

P.S: Don't flame me for pulling down K&R, to their standard & win the
argument by sheer experience.

.



Relevant Pages