470,874 Members | 1,435 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,874 developers. It's quick & easy.

i want to know what the following function is doing?

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[i]) && !inquote) || (s[i] == '"' &&
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[i] == '"');

}
}
f.size(nf);
}
Jun 27 '08 #1
0 1042

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Fredrik Melin | last post: by
182 posts views Thread by Jim Hubbard | last post: by
14 posts views Thread by Professor Yonce | last post: by
33 posts views Thread by Michael B Allen | last post: by
23 posts views Thread by Maarten | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.