Originally Posted by
Salem
> std::vector <std::string> * fill_vector(char *file)
You need to remove the *
You're not returning a pointer, you're returning an actual vector.
Assuming your header file includes <vector> and <string>.
Then make the parameter
const char *file
Ok
here is where I am at.
Code:
void fill_vector(char *file)
{
std::vector <std::string> FileList;
std::string sfile(file);
FileList.push_back(sfile);
int s = FileList.size();
for( int i = 0; i < s ; i++) {
std::cout << FileList[i]<< " vector"<< '\n';
}
// return FileList;
}
that works, I get output of every file in the directories .
when I change the to return
Code:
std::vector <std::string> fill_vector(char *file)
{
std::vector <std::string> FileList;
std::string sfile(file);
FileList.push_back(sfile);
/*
int s = FileList.size();
for( int i = 0; i < s ; i++) {
std::cout << FileList[i]<< " vector"<< '\n';
}
*/
return FileList;
}
header is the same as the declaration
Code:
std::vector <std::string> fill_vector(char *file);
still getting error, I too added the include vector header file, as stated It is getting filled . and prints out by the use of that loop within the function.
still gettting this
Code:
[Running] cd "/media/data/projects/VSC/C++/mh5000/" && g++ -Wall -std=gnu++1z *.cpp
In file included from main.cpp:3:0:
files.h:21:6: error: 'vector' in namespace 'std' does not name a template type
std::vector <std::string> fill_vector(char *file);
^~~~~~
In file included from options.cpp:4:0:
files.h:21:6: error: 'vector' in namespace 'std' does not name a template type
std::vector <std::string> fill_vector(char *file);
both main.cpp, and options.cpp have the #include "files.h "
so I got to stick #include <vector> in every cpp that is not even using it within the cpp of that file if one file (cpp) is using it?
because that is what I did and the errors are no longer there.
the pointer what a shot in the dark . but yeah. ok