View Single Post
Join Date: Aug 2005
Posts: 15,149
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1435
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Most Valuable Poster

Re: Iterator assertion failure. How?

 
0
  #7
May 16th, 2008
you must have something else wrong because your function compiled ok for me. All I did was make it a simple function and declare the vector globally.

  1. #include <iostream>
  2. #include <string>
  3. #include <io.h>
  4. #include <vector>
  5. using namespace std;
  6.  
  7. vector<string> m_vFilenames;
  8. int MakeList(string p_sPath)
  9. {
  10. cout << "Parameter: " << p_sPath << endl;
  11. struct _finddatai64_t struct_filedata;
  12. string s_filename = p_sPath + "\\*.*";
  13. string s_current = ".";
  14. string s_parrent = "..";
  15.  
  16. cout << "Listing " << s_filename << endl;
  17.  
  18. long nHandle = _findfirsti64(s_filename.c_str(), &struct_filedata);
  19. if(nHandle >= 0)
  20. {
  21. while(_findnexti64(nHandle, &struct_filedata) == 0)
  22. {
  23. if(struct_filedata.attrib & _A_SUBDIR)
  24. {
  25. if( (s_current.compare(struct_filedata.name) && s_parrent.compare(struct_filedata.name)) )
  26. {
  27. s_filename = p_sPath + "\\" + struct_filedata.name;
  28. cout << "Subdir found: " << s_filename << endl;
  29. MakeList(s_filename);
  30. }
  31. else
  32. {
  33. cout << "Dir found: " << struct_filedata.name << endl;
  34. }
  35. }
  36. else
  37. {
  38. cout << "File found: " << struct_filedata.name << endl;
  39. m_vFilenames.push_back(struct_filedata.name);
  40. }
  41.  
  42. }
  43. }
  44. else
  45. {
  46. cout << "Path not found." << endl;
  47. return -1;
  48. }
  49.  
  50.  
  51. return 1;
  52. }
  53.  
  54. int main()
  55. {
  56.  
  57. }
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote