Re: An interview question by MS
- From: "robertwessel2@xxxxxxxxx" <robertwessel2@xxxxxxxxx>
- Date: Tue, 06 Nov 2007 02:02:19 -0800
On Nov 6, 2:20 am, Lambda <stephenh...@xxxxxxxxx> wrote:
In an interview, I was asked:
Define a function to split a string with some token.
I said let the function return a string array.
He asked me how do i know the array size.
Yes, I have to traverse the string to find how large the array is for
the first time.
And traverse the string when actually doing the split for the second
time.
I think this is maybe not the correct answer.
How should i handle such situation?
I find there is a 'strtok(s, ct)' function in the standard library.
The first cll in a sequence has a non-NULL s.
Each subsequent call, indicated by a NULL value of s.
strtok returns NULL when no further token is found.
Why indeed this function defined this way?
Why not return a string array directly?
Maybe this is the correct answer??
I find it highly improbably that an MS interview question was intended
to elicit a C response. Surely the desired response was to create and
return a C++ container object in some fashion.
.
- Follow-Ups:
- Re: An interview question by MS
- From: Lambda
- Re: An interview question by MS
- From: santosh
- Re: An interview question by MS
- References:
- An interview question by MS
- From: Lambda
- An interview question by MS
- Prev by Date: Re: Bug/Gross InEfficiency in HeathField's fgetline program
- Next by Date: Re: An interview question by MS
- Previous by thread: Re: An interview question by MS
- Next by thread: Re: An interview question by MS
- Index(es):
Relevant Pages
|