I'm trying to load from a file i was just wondering if anyone can see if there are any syntax errors
P.S. my save part of the code works.
thanks in advance for help
[code=c++]
ofstream myfile;
ifstream load_file("Game save.txt");
string line;
class BadConversion : public std::runtime_er ror {
public:
BadConversion(c onst std::string& line)
: std::runtime_er ror(line)
{ }
};
inline double convertToDouble (const std::string& line)
{
std::istringstr eam i(line);
double x;
if (!(i >> x))
throw BadConversion(" convertToDouble (\"" + line + "\")");
return x;
}
if(load_file.is _open())
{
while(! load_file.eof() )
{
getline (load_file,line );
money = convertToDouble (line);
//cout<<"Here is your previous game winnings: ";
//cout << money << "\n";
//Sleep(3000);
}
load_file.close ();
}
[/code]
P.S. my save part of the code works.
thanks in advance for help
[code=c++]
ofstream myfile;
ifstream load_file("Game save.txt");
string line;
class BadConversion : public std::runtime_er ror {
public:
BadConversion(c onst std::string& line)
: std::runtime_er ror(line)
{ }
};
inline double convertToDouble (const std::string& line)
{
std::istringstr eam i(line);
double x;
if (!(i >> x))
throw BadConversion(" convertToDouble (\"" + line + "\")");
return x;
}
if(load_file.is _open())
{
while(! load_file.eof() )
{
getline (load_file,line );
money = convertToDouble (line);
//cout<<"Here is your previous game winnings: ";
//cout << money << "\n";
//Sleep(3000);
}
load_file.close ();
}
[/code]
Comment