A
Allan Bruce
I want to load config from a file. I know how to load in numbers using an
ifstream, but I cant get it to load a string. Can somebody tell me how to
load a string from file? Here is my code:
int mNumServers;
short *mPorts;
std::string *mServers;
std::string *mPaths;
std::ifstream infile(HST_SERVERS_FILE);
infile >> mNumServers;
AllocServersMem();
for (int i=0; i<mNumServers; i++)
{
std::string temp;
// XXX how do I load a string easily?
//infile >> mServers;
//infile >> mPaths;
infile >> mPorts;
}
infile.close();
I get an error saying that:
error C2679: binary '>>' : no operator found which takes a right-hand
operand of type 'std::string' (or there is no acceptable conversion)
Thanks
Allan
ifstream, but I cant get it to load a string. Can somebody tell me how to
load a string from file? Here is my code:
int mNumServers;
short *mPorts;
std::string *mServers;
std::string *mPaths;
std::ifstream infile(HST_SERVERS_FILE);
infile >> mNumServers;
AllocServersMem();
for (int i=0; i<mNumServers; i++)
{
std::string temp;
// XXX how do I load a string easily?
//infile >> mServers;
//infile >> mPaths;
infile >> mPorts;
}
infile.close();
I get an error saying that:
error C2679: binary '>>' : no operator found which takes a right-hand
operand of type 'std::string' (or there is no acceptable conversion)
Thanks
Allan