As an aside to your primary question, that call to main() at the end of your function void list(vector<string>files) - what is that for? Why are you calling main from within a function?
I think we might need to see your main() function to work out the problem. The code below works as expected.
Code:#include <vector> #include <string> #include <iostream> int main() { using std::vector; using std::string; using std::cout; vector<string> files; files.push_back("C:/bills/default.txt"); files.push_back("C:/bills/jan.txt"); files.push_back("C:/bills/feb.txt"); files.push_back("C:/bills/mar.txt"); files.push_back("C:/bills/april.txt"); files.push_back("C:/bills/may.txt"); files.push_back("C:/bills/june.txt"); files.push_back("C:/bills/july.txt"); files.push_back("C:/bills/aug.txt"); files.push_back("C:/bills/sept.txt"); files.push_back("C:/bills/oct.txt"); files.push_back("C:/bills/nov.txt"); files.push_back("C:/bills/dec.txt"); string file; file=files[0]; cout << file; return 0; }




Reply With Quote