boost::shared_ptr<model> model::loadmodel(const string filename)
{
fstream file;
file.open(filename);
It seems to want filename as a const char*, so how do I convert a string to an array of chars? I tried filename.c_str, but it thought that was <unknown type>
Yagh....ifstream
I'm having trouble getting this to compile.
filename.c_str() should work fine, or I suppose you could just make a char array and copy your string elements into it a character at a time...
well, make the function parameter a const character array. and then when you call it you can just do: filename.c_str() in the call.
If you tried this, sorry.
If you tried this, sorry.
Quote:Original post by NIm
I tried filename.c_str, but it thought that was <unknown type>
You probably forgot to #include <string>. filename.c_str() is the correct way to to it.
You shound probably pass your filename by reference rather than value (const string & filename) and open the file when you initialise it (fstream file(filename.c_str());), since this is more idiomatic C++.
Σnigma
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement