i want to know what the following function is doing?

Discussion in 'C Programming' started by amit129, May 27, 2008.

  1. amit129

    amit129 Guest

    hi,

    Please tell me what the below mentined code is doing? If i pass String
    s as my name is "xyz. and " i am writing . what should be the output.

    Thanks in advance

    void parse(Block<String>& f, String s)
    {
    int inquote = 0;
    int nf = 0;
    int start = -1;
    for(int i = 0; i <= length(s); i++){
    if(i == length(s) || (isspace(s) && !inquote) || (s == '"' &&
    inquote)){
    if(start != -1){
    nf++;
    f.reserve(nf);
    if(inquote && i != length(s))
    f[nf-1] = s(start,i-start+1);
    else
    f[nf-1] = s(start,i-start);
    start = -1;
    inquote = 0;
    }
    }
    else if(start == -1){
    start = i;
    inquote = (s == '"');
    }
    }
    f.size(nf);
    }

    Amit
    amit129, May 27, 2008
    #1
    1. Advertising

  2. amit129 <> wrote:
    > Please tell me what the below mentined code is doing? If i pass String
    > s as my name is "xyz. and " i am writing . what should be the output.


    > void parse(Block<String>& f, String s)


    Why don't you put it into a simple program and just test what
    it does? Moreover, you picked the wrong newsgroup, this one is
    for C, not C++. The experts for C++ are on the other side of
    the hallway in comp.lang.c++.
    Regards, Jens
    --
    \ Jens Thoms Toerring ___
    \__________________________ http://toerring.de
    Jens Thoms Toerring, May 27, 2008
    #2
    1. Advertising

  3. On Tue, May 27, 2008 at 03:13:31AM -0700, amit129 wrote:
    > hi,
    >
    > Please tell me what the below mentined code is doing? If i pass String
    > s as my name is "xyz. and " i am writing . what should be the output.
    >
    > Thanks in advance
    >
    > void parse(Block<String>& f, String s)


    Uups, you forgot to append a ++ to the newsgroup name. And please
    resist the temptation to think that C++ is C. Beleive or not,
    even your innocent looking '"' has very different meanings in the
    two languages, so the advice we could give will probably not apply to you
    problem.

    Szabolcs
    Szabolcs Borsanyi, May 27, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. maadhuu

    want to know hoe the following works .

    maadhuu, Aug 13, 2005, in forum: C Programming
    Replies:
    4
    Views:
    413
    Michael Mair
    Aug 13, 2005
  2. amit129
    Replies:
    0
    Views:
    251
    amit129
    May 27, 2008
  3. Simon Egginton

    LOOK! i just want to know does anyone know...

    Simon Egginton, Jul 26, 2004, in forum: Javascript
    Replies:
    3
    Views:
    176
    Dr John Stockton
    Jul 26, 2004
  4. Andries

    I know, I know, I don't know

    Andries, Apr 23, 2004, in forum: Perl Misc
    Replies:
    3
    Views:
    228
    Gregory Toomey
    Apr 23, 2004
  5. windandwaves
    Replies:
    2
    Views:
    62
    windandwaves
    Dec 7, 2006
Loading...

Share This Page