Another question, inline functions, and how to make it so a funtion outside can access the loaded file. Such as "file" in the above example.
When I try to do as I explain above I get:
Originally Posted by
compiler
c:\docume~1\owner\mydocu~1\parsing\todesr~1.cpp:80 : initializing non-const `ifstream &' with `const char *' will use a temporary
c:\docume~1\owner\mydocu~1\parsing\todesr~1.cpp: In method `ifstream::ifstream(const ifstream &)':
C:\DEV-C_~1\Include\G__~1\streambuf.h:128: `ios::ios(const ios &)' is private
c:\docume~1\owner\mydocu~1\parsing\todesr~1.cpp:80 : within this context
c:\docume~1\owner\mydocu~1\parsing\todesr~1.cpp: In method `fstreambase::fstreambase(const fstreambase &)':
C:\DEV-C_~1\Include\G__~1\streambuf.h:128: `ios::ios(const ios &)' is private
c:\docume~1\owner\mydocu~1\parsing\todesr~1.cpp:80 : within this context
c:\docume~1\owner\mydocu~1\parsing\todesr~1.cpp: In method `istream::istream(const istream &)':
C:\DEV-C_~1\Include\G__~1\streambuf.h:128: `ios::ios(const ios &)' is private
c:\docume~1\owner\mydocu~1\parsing\todesr~1.cpp:80 : within this context
Code:
inline void loadfile(ifstream& file("runes"))
{
ifstream file( "Runes.txt");
if (!file.is_open())
ifstream file( "runes.txt");
if (!file.is_open())
ifstream file( "rune.txt");
if (!file.is_open())
ifstream file( "Rune.txt");
if (!file.is_open())
{
string filename;
cout<<"TodesRunes could not find your ATMA dump"<<endl<<"please specify the path to the txt file."<<endl;
cin>>filename;
ifstream file( filename.c_str());
}
if (!file.is_open())
cout<<"The file does not appear to be here!";
}
Code:
int main ()
{
int el = 0, eld = 0, tir = 0, nef = 0, eth = 0, ith = 0, tal = 0, ral = 0, ort = 0, thul = 0,amn = 0,
sol = 0, shael = 0, dol = 0, hel = 0, io = 0, lum = 0, ko = 0, fal = 0, lem = 0,pul = 0, um = 0,
mal = 0, ist = 0, gul = 0, vex = 0, ohm = 0, lo = 0, sur = 0, ber = 0, jah = 0, cham = 0, zod = 0;
loadfile();
cout << "Loading your ATMA readout and parsing now" << endl;
string line;
while (getline( file , line ))
{
if (line.empty() || (line == "\r")) continue;
int colon_pos = line.find(':');
string rune = line.substr(colon_pos+2,line.size()-colon_pos-7);
if (rune == "El")
el++;
else if (rune == "Eld")
eld++;
else if (rune == "Tir")
tir++;
else if (rune == "Nef")
nef++;
else if (rune == "Eth")
eth++;
The main continues on, but I think I included the parts that would help people to help me.