E
edu.mvk
Hi, i have the following code which updates the vector of strings(
p_vector ) each time it goes into the loop
for the first iteration we have only one string in the vector. But in
the while loop we are updating the vector and adding few more strings
at the end.
I'm expecting that In the second iteration the "it" should point to the
updated vector, but it is pointing to the "NULL".
for(vector<string>::iterator it = p_vector.begin(); it !=
p_vector.end(); it++)
{
LogInfo(("\nNext directory %s\n",it->c_str()));
pDirStream = opendir(it->c_str());
LogInfo(("\n%s Directory
opened\n",it->c_str()));
while(pDirEntry = readdir(pDirStream) )
{
if( pDirEntry->d_type == DT_DIR )
{
count++;
if(count>2)
{
l_Name.append("/");
l_Name.append(string(pDirEntry->d_name));
LogInfo(("\n\nThe
subpath is: %s\n",l_Name.c_str()));
p_vector.push_back(l_Name);
l_Name.assign(p_Name);
}
}
}
closedir(pDirStream);
count = 0;
}
Please explain why the "it" pointing to NULL and how can i point to the
updated vector in the second and subsequent iterations of the for loop.
Thanks,
p_vector ) each time it goes into the loop
for the first iteration we have only one string in the vector. But in
the while loop we are updating the vector and adding few more strings
at the end.
I'm expecting that In the second iteration the "it" should point to the
updated vector, but it is pointing to the "NULL".
for(vector<string>::iterator it = p_vector.begin(); it !=
p_vector.end(); it++)
{
LogInfo(("\nNext directory %s\n",it->c_str()));
pDirStream = opendir(it->c_str());
LogInfo(("\n%s Directory
opened\n",it->c_str()));
while(pDirEntry = readdir(pDirStream) )
{
if( pDirEntry->d_type == DT_DIR )
{
count++;
if(count>2)
{
l_Name.append("/");
l_Name.append(string(pDirEntry->d_name));
LogInfo(("\n\nThe
subpath is: %s\n",l_Name.c_str()));
p_vector.push_back(l_Name);
l_Name.assign(p_Name);
}
}
}
closedir(pDirStream);
count = 0;
}
Please explain why the "it" pointing to NULL and how can i point to the
updated vector in the second and subsequent iterations of the for loop.
Thanks,