Re: An interview question by MS



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.

.



Relevant Pages

  • Re: Copy Array
    ... >> I have a single dimension string array. ... >around my string arrays so that I can set references, ... Dim sArryCopy() As String ... Dim lLp As Long ...
    (microsoft.public.vb.general.discussion)
  • Re: Gridview1 fired event Sorting which wasnt handled
    ... Dim dt As DataTable = DirectCast ... so the datasource is of type array string. ... DataTable variable and populate it with a string array - that's never ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: Excel ActiveX TextBox Question
    ... So what is the syntax for a string array? ... code a loop - put the characters in the array - and do a string compare. ... You need to get into design mode and set the linkedCell property ... View - Toolbars - Control toolbox. ...
    (microsoft.public.excel.misc)
  • Re: NameValueCollections GetValues does not return multiple entries
    ... > For key1 I am getting an array with a single string "Value1,Value2", ... >> Hello Vagif, ... The NameValueCollection returns a string array based on a string ... When I use AppSettings and try to retrieve multiple values ...
    (microsoft.public.dotnet.framework)
  • An interview question by MS
    ... Define a function to split a string with some token. ... I said let the function return a string array. ... the first time. ... And traverse the string when actually doing the split for the second ...
    (comp.lang.c)