i want to know what the following function is doing?

Discussion in 'C++' 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);
    }
     
    amit129, May 27, 2008
    #1
    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:
    421
    Michael Mair
    Aug 13, 2005
  2. amit129
    Replies:
    2
    Views:
    226
    Szabolcs Borsanyi
    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:
    183
    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:
    254
    Gregory Toomey
    Apr 23, 2004
  5. windandwaves
    Replies:
    2
    Views:
    65
    windandwaves
    Dec 7, 2006
Loading...

Share This Page