i want to know what the following function is doing?

A

amit129

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
 
J

Jens Thoms Toerring

amit129 said:
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
 
S

Szabolcs Borsanyi

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,189
Latest member
CryptoTaxSoftware

Latest Threads

Top