Thread: Converted from Dev-C++ 4 to Dev-C++ 5

  1. #1
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094

    Converted from Dev-C++ 4 to Dev-C++ 5

    Ok, as the thread title says, I conveted to the newest release. I updated everything, now when I try and compile a program that previously worked, it wont =/

    Quote Originally Posted by Dev-C++ 5
    C:\Documents and Settings\Owner\My Documents\Parsing\TodesRunes.cpp: In function `void SaveNoCube(std:fstream&, int&, int&, int&, int&, int&, int&, int&, int&, int&, int&, int&, int&, int&, int&, int&, int&, int&, int&, int&, int&, int&, int&, int&, int&, int&, int&, int&, int&, int&, int&, int&, int&, int&)':
    C:\Documents and Settings\Owner\My Documents\Parsing\TodesRunes.cpp:236: error: a function-definition is not allowed here before '{' token
    C:\Documents and Settings\Owner\My Documents\Parsing\TodesRunes.cpp:236: error: expected `,' or `;' before '{' token
    C:\Documents and Settings\Owner\My Documents\Parsing\TodesRunes.cpp:289: error: a function-definition is not allowed here before '{' token
    C:\Documents and Settings\Owner\My Documents\Parsing\TodesRunes.cpp:289: error: expected `,' or `;' before '{' token
    C:\Documents and Settings\Owner\My Documents\Parsing\TodesRunes.cpp:326: error: expected primary-expression before "int"
    C:\Documents and Settings\Owner\My Documents\Parsing\TodesRunes.cpp:326: error: expected `;' before "int"
    C:\Documents and Settings\Owner\My Documents\Parsing\TodesRunes.cpp:409: error: expected `}' at end of input
    Code:
    #include <iostream>
    #include <fstream>
    #include <string>
    
    using namespace std;
    //Cube Runes needing 3 to get next
    inline void combo1(int& first, int& second)
    {
        while (first>=3)
        {
        first-=3;
        second++;
        }
    }
    //Cube Runes needing 2 to get next
    inline void combo2(int& first, int& second)
    {
        while (first>=2)
        {
        first-=2;
        second++;
        }
    }
    //Cubing
    inline void cube(int& el, int& eld, int& tir, int& nef, int& eth, int& ith, int& tal,
                     int& ral, int& ort, int& thul, int& amn, int& sol, int& shael,
                     int& dol, int& hel, int& io, int& lum, int& ko, int& fal, int& lem,
                     int& pul, int& um, int& mal, int& ist, int& gul, int& vex, int& ohm,
                     int& lo, int& sur, int& ber, int& jah, int& cham, int& zod)
    {
        combo1(el,eld);
        combo1(eld,tir);
        combo1(tir,nef);
        combo1(nef,eth);
        combo1(eth,ith);
        combo1(ith,tal);
        combo1(tal,ral);
        combo1(ral,ort);
        combo1(ort,thul);
        combo1(thul,amn);
        combo1(amn,sol);
        combo1(sol,shael);
        combo1(shael,dol);
        combo1(dol,hel);
        combo1(hel,io);
        combo1(io,lum);
        combo1(lum,ko);
        combo1(ko,fal);
        combo1(fal,lem);
        combo1(lem,pul);
        combo2(pul,um);
        combo2(um,mal);
        combo2(mal,ist);
        combo2(ist,gul);
        combo2(gul,vex);
        combo2(vex,ohm);
        combo2(ohm,lo);
        combo2(lo,sur);
        combo2(sur,ber);
        combo2(ber,jah);
        combo2(jah,cham);
        combo2(cham,zod);
    }
    //Output to the console
    inline int output(int& el, int& eld, int& tir, int& nef, int& eth, int& ith,
                      int& tal, int& ral, int& ort, int& thul, int& amn, int& sol,
                      int& shael, int& dol, int& hel, int& io, int& lum, int& ko,
                      int& fal, int& lem, int& pul, int& um, int& mal, int& ist,
                      int& gul, int& vex, int& ohm, int& lo, int& sur, int& ber,
                      int& jah, int& cham, int& zod)
    {
        cout<<"El:" << el << "      " << "Eld:" << eld << endl << "Tir:" << tir << "     "
            << "Nef:" << nef  << endl << "Eth:" << eth << "     " << "Ith:" << ith
            << endl << "Tal:" << tal << "     " << "Ral:" << ral << endl << "Ort:" << ort
            << "     " << "Thul:" << thul << endl << "Amn:" << amn << "     " << "Sol:"
            << sol << endl << "Shael:" << shael << "   " << "Dol:" << dol << endl << "Hel:"
            << hel << "     " << "Io:" << io << endl << "Lum:" << lum << "     " << "Ko:"
            << ko << endl << "Fal:" << fal << "     " << "Lem:" << lem << endl << "Pul:"
            << pul << "     " "Um:" << um << endl << "Mal:" << mal << "     " << "Ist:"
            << ist << endl << "Gul:" << gul << "     " << "Vex:" << vex << endl << "Ohm:"
            << ohm << "     " << "Lo:" << lo << endl << "Sur:" << sur << "     " << "Ber:"
            << ber << endl << "Jah:" << jah << "     " << "Cham:" << cham << endl << "Zod:"
            << zod <<endl;
        return 0;
    }
    //Loads the atma dump
    inline void loadfile(ifstream& file)
    {
        while(!file.is_open())
        {
            file.open("Runes.txt");
            if (!file.is_open())
                file.open( "runes.txt");
                if (!file.is_open())
                    file.open( "rune.txt");
                    if (!file.is_open())
                        file.open( "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;
                            getline(cin,filename);
                            file.open(filename.c_str());
                        }
        }
    }
    //Tallies up all the runes from the dump
    inline void counter(int& el, int& eld, int& tir, int& nef, int& eth, int& ith,
                        int& tal, int& ral, int& ort, int& thul, int& amn, int& sol,
                        int& shael, int& dol, int& hel, int& io, int& lum, int& ko,
                        int& fal, int& lem, int& pul, int& um, int& mal, int& ist,
                        int& gul, int& vex, int& ohm, int& lo, int& sur, int& ber,
                        int& jah, int& cham, int& zod, ifstream& file)
    {
            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++;
                else if (rune == "Ith")
                    ith++;
                else if (rune == "Tal")
                    tal++;
                else if (rune == "Ral")
                    ral++;
                else if (rune == "Ort")
                    ort++;
                else if (rune == "Thul")
                    thul++;
                else if (rune == "Amn")
                    amn++;
                else if (rune == "Sol")
                    sol++;
                else if (rune == "Shael")
                    shael++;
                else if (rune == "Dol")
                    dol++;
                else if (rune == "Hel")
                    hel++;
                else if (rune == "Io")
                    io++;
                else if (rune == "Lum")
                    lum++;
                else if (rune == "Ko")
                    ko++;
                else if (rune == "Fal")
                    fal++;
                else if (rune == "Lem")
                    lem++;
                else if (rune == "Pul")
                    pul++;
                else if (rune == "Um")
                    um++;
                else if (rune == "Mal")
                    mal++;
                else if (rune == "Ist")
                    ist++;
                else if (rune == "Gul")
                    gul++;
                else if (rune == "Vex")
                    vex++;
                else if (rune == "Ohm")
                    ohm++;
                else if (rune == "Lo")
                    lo++;
                else if (rune == "Sur")
                    sur++;
                else if (rune == "Ber")
                    ber++;
                else if (rune == "Jah")
                    jah++;
                else if (rune == "Cham")
                    cham++;
                else if (rune == "Zod")
                    zod++;
        	}
    }
    //Dump info to txt file, if no cubing has been done.
    inline void SaveNoCube(ofstream& save,int& el, int& eld, int& tir, int& nef,
                           int& eth, int& ith, int& tal, int& ral, int& ort, int& thul,
                           int& amn, int& sol, int& shael, int& dol, int& hel, int& io,
                           int& lum, int& ko, int& fal, int& lem, int& pul, int& um,
                           int& mal, int& ist, int& gul, int& vex, int& ohm, int& lo,
                           int& sur, int& ber, int& jah, int& cham, int& zod)
    {
    
        string filename;
        cout<<"Specify path if you had to when loading."<<endl<<"Save name:"<<endl;
        getline(cin,filename);
        save.open(filename.c_str());
        if (!save.is_open())
            cout<<"The file did not open!";
        else
            save<<"Total Runes: "<<el + eld + tir + nef + eth + ith + tal + ral + ort
                                 + thul + amn + sol + shael + dol + hel + io + lum +
                                 ko + fal + lem + pul + um + mal + ist + gul + vex +
                                 ohm + lo + sur + ber + jah + cham + zod <<endl;
            save<<"El:" << el << "      " << "Eld:" << eld << endl << "Tir:" << tir
                << "     " << "Nef:" << nef  << endl << "Eth:" << eth << "     "
                <<"Ith:" << ith << endl << "Tal:" << tal << "     " << "Ral:" << ral
                << endl << "Ort:" << ort << "     " << "Thul:" << thul << endl << "Amn:"
                << amn << "     " << "Sol:" << sol << endl << "Shael:" << shael << "   "
                << "Dol:" << dol << endl << "Hel:" << hel << "     " << "Io:" << io
                << endl << "Lum:" << lum << "     " << "Ko:" << ko << endl << "Fal:"
                << fal << "     " << "Lem:" << lem << endl << "Pul:" << pul << "     "
                <<"Um:" << um << endl << "Mal:" << mal << "     " << "Ist:" << ist
                << endl << "Gul:" << gul << "     " << "Vex:" << vex << endl << "Ohm:"
                << ohm << "     " << "Lo:" << lo << endl << "Sur:" << sur << "     "
                << "Ber:" << ber << endl << "Jah:" << jah << "     " << "Cham:" << cham
                << endl << "Zod:" << zod <<endl;
    
    inline void SaveCube(ofstream& save, int& el, int& eld, int& tir, int& nef, 
                         int& eth, int& ith, int& tal, int& ral, int& ort, int& thul, 
                         int& amn, int& sol, int& shael, int& dol, int& hel, int& io,
                         int& lum, int& ko, int& fal, int& lem, int& pul, int& um,
                         int& mal, int& ist, int& gul, int& vex, int& ohm, int& lo,
                         int& sur, int& ber, int& jah, int& cham, int& zod, int& el2,
                         int& eld2, int& tir2, int& nef2, int& eth2, int& ith2, int& tal2,
                         int& ral2, int& ort2, int& thul2, int& amn2, int& sol2, int& shael2,
                         int& dol2, int& hel2, int& io2, int& lum2, int& ko2, int& fal2,
                         int& lem2, int& pul2, int& um2, int& mal2, int& ist2, int& gul2,
                         int& vex2, int& ohm2, int& lo2, int& sur2, int& ber2, int& jah2,
                         int& cham2, int& zod2)
    {
        string filename;
        cout<<"Specify path if you had to when loading."<<endl<<"Save name:"<<endl;
        getline(cin,filename);
        save.open(filename.c_str());
        if (!save.is_open())
            cout<<"The file did not open!";
        else
            save<<"Total Runes: "<<el + eld + tir + nef + eth + ith + tal + ral + ort
                                   + thul + amn + sol + shael + dol + hel + io + lum
                                   + ko + fal + lem + pul + um + mal + ist + gul + vex
                                   + ohm + lo + sur + ber + jah + cham + zod <<endl;
    
            save<<"\nEl:" << el << "      " << "Eld:" << eld << endl << "Tir:" << tir << "     "
                << "Nef:" << nef  << endl << "Eth:" << eth << "     " << "Ith:" << ith
                << endl << "Tal:" << tal << "     " << "Ral:" << ral << endl << "Ort:" << ort
                << "     " << "Thul:" << thul << endl << "Amn:" << amn << "     " << "Sol:"
                << sol << endl << "Shael:" << shael << "   " << "Dol:" << dol << endl << "Hel:"
                << hel << "     " << "Io:" << io << endl << "Lum:" << lum << "     " << "Ko:"
                << ko << endl << "Fal:" << fal << "     " << "Lem:" << lem << endl << "Pul:"
                << pul << "     " "Um:" << um << endl << "Mal:" << mal << "     " << "Ist:"
                << ist << endl << "Gul:" << gul << "     " << "Vex:" << vex << endl << "Ohm:"
                << ohm << "     " << "Lo:" << lo << endl << "Sur:" << sur << "     " << "Ber:"
                << ber << endl << "Jah:" << jah << "     " << "Cham:" << cham << endl << "Zod:"
                << zod <<endl
                << "\nAfter cubing"<< endl
                <<"\nEl:" << el2 << "      " << "Eld:" << eld2 << endl << "Tir:" << tir2 << "     "
                << "Nef:" << nef2  << endl << "Eth:" << eth2 << "     " << "Ith:" << ith2
                << endl << "Tal:" << tal2 << "     " << "Ral:" << ral2 << endl << "Ort:" << ort2
                << "     " << "Thul:" << thul2 << endl << "Amn:" << amn2 << "     " << "Sol:"
                << sol2 << endl << "Shael:" << shael2 << "   " << "Dol:" << dol2 << endl << "Hel:"
                << hel2 << "     " << "Io:" << io2 << endl << "Lum:" << lum2 << "     " << "Ko:"
                << ko2 << endl << "Fal:" << fal2 << "     " << "Lem:" << lem2 << endl << "Pul:"
                << pul2 << "     " "Um:" << um2 << endl << "Mal:" << mal2 << "     " << "Ist:"
                << ist2 << endl << "Gul:" << gul2 << "     " << "Vex:" << vex2 << endl << "Ohm:"
                << ohm2 << "     " << "Lo:" << lo2 << endl << "Sur:" << sur2 << "     " << "Ber:"
                << ber2 << endl << "Jah:" << jah2 << "     " << "Cham:" << cham2 << endl << "Zod:"
                << zod2 <<endl;
    
    }
    //copies all the tallied up runes into another variable, used to cube so outputting both is possible
    inline void swap(int& el, int& eld, int& tir, int& nef, int& eth, int& ith,
                     int& tal, int& ral, int& ort, int& thul, int& amn, int& sol,
                     int& shael, int& dol, int& hel, int& io, int& lum, int& ko,
                     int& fal, int& lem, int& pul, int& um, int& mal, int& ist,
                     int& gul, int& vex, int& ohm, int& lo, int& sur, int& ber,
                     int& jah, int& cham, int& zod, int& el2, int& eld2,
                         int& tir2, int& nef2, int& eth2, int& ith2, int& tal2, int& ral2,
                         int& ort2, int& thul2, int& amn2, int& sol2, int& shael2,
                         int& dol2, int& hel2, int& io2, int& lum2, int& ko2, int& fal2,
                         int& lem2, int& pul2, int& um2, int& mal2, int& ist2, int& gul2,
                         int& vex2, int& ohm2, int& lo2, int& sur2, int& ber2, int& jah2,
                         int& cham2, int& zod2)
    {
        el2 = el;
        eld2 = eld;
        tir2 = tir;
        nef2 = nef;
        eth2 = eth;
        ith2 = ith;
        tal2 = tal;
        ral2 = ral;
        ort2 = ort;
        thul2 = thul;
        amn2 = amn;
        sol2 = sol;
        shael2 = shael;
        dol2 = dol;
        hel2 = hel;
        io2 = io;
        lum2 = lum;
        ko2 = ko;
        fal2 = fal;
        lem2 = lem;
        pul2 = pul;
        um2 = um;
        mal2 = mal;
        ist2 = ist;
        gul2 = gul;
        vex2 = vex;
        ohm2 = ohm;
        lo2 = lo;
        sur2 = lo;
        ber2 = ber;
        jah2 = jah;
        cham2 = cham;
        zod2 = zod;
    }
    
    
    int main ()
    {
        cout<<"Welcome to TodesRunes 1.1!"<<endl;
        int run = 1;     //menu choice
        int cubed = 0;   //if the cubing function has been called
        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,
            int el2 = 0, eld2 = 0, tir2 = 0, nef2 = 0, eth2 = 0, ith2 = 0, tal2 = 0,
            ral2 = 0, ort2 = 0, thul2 = 0,amn2 = 0, sol2 = 0, shael2 = 0, dol2 = 0,
            hel2 = 0, io2 = 0, lum2 = 0, ko2 = 0, fal2 = 0, lem2 = 0,pul2 = 0, um2 = 0,
            mal2 = 0, ist2 = 0, gul2 = 0, vex2 = 0, ohm2 = 0, lo2 = 0, sur2 = 0, ber2 = 0,
            jah2 = 0, cham2 = 0, zod2 = 0;
            // ^^^ all the rune variables
        ifstream file;     //ATMA dump
        ofstream save;     //TodesRune dump
    
        loadfile(file);    //loads the ATMA dump
    
        counter(el, eld, tir, nef, eth, ith, tal, ral, ort, thul, amn,  //counts the runes in the dump
                sol, shael, dol, hel, io, lum, ko, fal, lem, pul, um,
                mal, ist, gul, vex, ohm, lo, sur, ber, jah, cham, zod, file);
    
    
        //outputs the total runes the console
        cout<< "There are "<<el + eld + tir + nef + eth + ith + tal + ral + ort + thul
               + amn + sol + shael + dol + hel + io + lum + ko + fal + lem + pul + um +
               mal + ist + gul + vex + ohm + lo + sur + ber + jah + cham + zod
               <<" runes that have been sorted" << endl;
        //menu
        while(run!=4)
        {
            cout<<"1. Cube all runes to the max."<<endl<<"2. Display current runes."<<
            endl<<"3. Save data to a file."<<endl<<"4. Blame Durf!!!! (quit)"<<endl<<"Choice: ";
            cin>>run;
            cin.ignore();
            switch(run)
            {
                case 1:
                    swap(el, eld, tir, nef, eth, ith, tal, ral, ort, thul, amn,
                         sol, shael, dol, hel, io, lum, ko, fal, lem, pul, um,
                         mal, ist, gul, vex, ohm, lo, sur, ber, jah, cham, zod,
                         el2, eld2, tir2, nef2, eth2, ith2, tal2, ral2, ort2, thul2, amn2,
                         sol2, shael2, dol2, hel2, io2, lum2, ko2, fal2, lem2, pul2, um2,
                         mal2, ist2, gul2, vex2, ohm2, lo2, sur2, ber2, jah2, cham2, zod2);
                    cube(el2, eld2, tir2, nef2, eth2, ith2, tal2, ral2, ort2, thul2, amn2,
                         sol2, shael2, dol2, hel2, io2, lum2, ko2, fal2, lem2, pul2, um2,
                         mal2, ist2, gul2, vex2, ohm2, lo2, sur2, ber2, jah2, cham2, zod2);
                    cubed = 1;
                    output(el2, eld2, tir2, nef2, eth2, ith2, tal2, ral2, ort2, thul2, amn2,
                         sol2, shael2, dol2, hel2, io2, lum2, ko2, fal2, lem2, pul2, um2,
                         mal2, ist2, gul2, vex2, ohm2, lo2, sur2, ber2, jah2, cham2, zod2);
                    break;
                case 2:
                    output(el, eld, tir, nef, eth, ith, tal, ral, ort, thul, amn,
                           sol, shael, dol, hel, io, lum, ko, fal, lem, pul, um,
                           mal, ist, gul, vex, ohm, lo, sur, ber, jah, cham, zod);
                    break;
                case 3:
                    if(cubed=0)
                    {
                        SaveNoCube(save, el, eld, tir, nef, eth, ith, tal, ral, ort, thul, amn,
                                   sol, shael, dol, hel, io, lum, ko, fal, lem, pul, um,
                                   mal, ist, gul, vex, ohm, lo, sur, ber, jah, cham, zod);
                    }
                    else
                    {
                        SaveCube(save, el, eld, tir, nef, eth, ith, tal, ral, ort, thul, amn,
                                 sol, shael, dol, hel, io, lum, ko, fal, lem, pul, um,
                                 mal, ist, gul, vex, ohm, lo, sur, ber, jah, cham, zod,
                                 el2, eld2, tir2, nef2, eth2, ith2, tal2, ral2, ort2, thul2, amn2,
                                 sol2, shael2, dol2, hel2, io2, lum2, ko2, fal2, lem2, pul2, um2,
                                 mal2, ist2, gul2, vex2, ohm2, lo2, sur2, ber2, jah2, cham2, zod2);
                    }
                    break;
                default:
                    cout<<"You entered an invalid response, please try agian"<<endl;
                    break;
            }
        }
        return 0;
    }
    If anyone could lead me to my errors, that would be great. Also any tips on making the program faster would be good also. I converted to 5 because it is easier to get GTK and wxWidgets installed on them, but now I don't know if it was worth it.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Find the //!! comments

    Code:
    #include <iostream>
    #include <fstream>
    #include <string>
    
    using namespace std;
    //Cube Runes needing 3 to get next
    inline void combo1(int& first, int& second)
    {
      while (first>=3)
      {
        first-=3;
        second++;
      }
    }
    //Cube Runes needing 2 to get next
    inline void combo2(int& first, int& second)
    {
      while (first>=2)
      {
        first-=2;
        second++;
      }
    }
    //Cubing
    inline void cube(int& el, int& eld, int& tir, int& nef, int& eth, int& ith, int& tal,
                     int& ral, int& ort, int& thul, int& amn, int& sol, int& shael,
                     int& dol, int& hel, int& io, int& lum, int& ko, int& fal, int& lem,
                     int& pul, int& um, int& mal, int& ist, int& gul, int& vex, int& ohm,
                     int& lo, int& sur, int& ber, int& jah, int& cham, int& zod)
    {
      combo1(el,eld);
      combo1(eld,tir);
      combo1(tir,nef);
      combo1(nef,eth);
      combo1(eth,ith);
      combo1(ith,tal);
      combo1(tal,ral);
      combo1(ral,ort);
      combo1(ort,thul);
      combo1(thul,amn);
      combo1(amn,sol);
      combo1(sol,shael);
      combo1(shael,dol);
      combo1(dol,hel);
      combo1(hel,io);
      combo1(io,lum);
      combo1(lum,ko);
      combo1(ko,fal);
      combo1(fal,lem);
      combo1(lem,pul);
      combo2(pul,um);
      combo2(um,mal);
      combo2(mal,ist);
      combo2(ist,gul);
      combo2(gul,vex);
      combo2(vex,ohm);
      combo2(ohm,lo);
      combo2(lo,sur);
      combo2(sur,ber);
      combo2(ber,jah);
      combo2(jah,cham);
      combo2(cham,zod);
    }
    //Output to the console
    inline int output(int& el, int& eld, int& tir, int& nef, int& eth, int& ith,
                      int& tal, int& ral, int& ort, int& thul, int& amn, int& sol,
                      int& shael, int& dol, int& hel, int& io, int& lum, int& ko,
                      int& fal, int& lem, int& pul, int& um, int& mal, int& ist,
                      int& gul, int& vex, int& ohm, int& lo, int& sur, int& ber,
                      int& jah, int& cham, int& zod)
    {
      cout<<"El:" << el << "      " << "Eld:" << eld << endl << "Tir:" << tir << "     "
          << "Nef:" << nef  << endl << "Eth:" << eth << "     " << "Ith:" << ith
          << endl << "Tal:" << tal << "     " << "Ral:" << ral << endl << "Ort:" << ort
          << "     " << "Thul:" << thul << endl << "Amn:" << amn << "     " << "Sol:"
          << sol << endl << "Shael:" << shael << "   " << "Dol:" << dol << endl << "Hel:"
          << hel << "     " << "Io:" << io << endl << "Lum:" << lum << "     " << "Ko:"
          << ko << endl << "Fal:" << fal << "     " << "Lem:" << lem << endl << "Pul:"
          << pul << "     " "Um:" << um << endl << "Mal:" << mal << "     " << "Ist:"
          << ist << endl << "Gul:" << gul << "     " << "Vex:" << vex << endl << "Ohm:"
          << ohm << "     " << "Lo:" << lo << endl << "Sur:" << sur << "     " << "Ber:"
          << ber << endl << "Jah:" << jah << "     " << "Cham:" << cham << endl << "Zod:"
          << zod <<endl;
      return 0;
    }
    //Loads the atma dump
    inline void loadfile(ifstream& file)
    {
      while(!file.is_open())
      {
        file.open("Runes.txt");
        if (!file.is_open())
          file.open( "runes.txt");
        if (!file.is_open())
          file.open( "rune.txt");
        if (!file.is_open())
          file.open( "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;
          getline(cin,filename);
          file.open(filename.c_str());
        }
      }
    }
    //Tallies up all the runes from the dump
    inline void counter(int& el, int& eld, int& tir, int& nef, int& eth, int& ith,
                        int& tal, int& ral, int& ort, int& thul, int& amn, int& sol,
                        int& shael, int& dol, int& hel, int& io, int& lum, int& ko,
                        int& fal, int& lem, int& pul, int& um, int& mal, int& ist,
                        int& gul, int& vex, int& ohm, int& lo, int& sur, int& ber,
                        int& jah, int& cham, int& zod, ifstream& file)
    {
      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++;
        else if (rune == "Ith")
          ith++;
        else if (rune == "Tal")
          tal++;
        else if (rune == "Ral")
          ral++;
        else if (rune == "Ort")
          ort++;
        else if (rune == "Thul")
          thul++;
        else if (rune == "Amn")
          amn++;
        else if (rune == "Sol")
          sol++;
        else if (rune == "Shael")
          shael++;
        else if (rune == "Dol")
          dol++;
        else if (rune == "Hel")
          hel++;
        else if (rune == "Io")
          io++;
        else if (rune == "Lum")
          lum++;
        else if (rune == "Ko")
          ko++;
        else if (rune == "Fal")
          fal++;
        else if (rune == "Lem")
          lem++;
        else if (rune == "Pul")
          pul++;
        else if (rune == "Um")
          um++;
        else if (rune == "Mal")
          mal++;
        else if (rune == "Ist")
          ist++;
        else if (rune == "Gul")
          gul++;
        else if (rune == "Vex")
          vex++;
        else if (rune == "Ohm")
          ohm++;
        else if (rune == "Lo")
          lo++;
        else if (rune == "Sur")
          sur++;
        else if (rune == "Ber")
          ber++;
        else if (rune == "Jah")
          jah++;
        else if (rune == "Cham")
          cham++;
        else if (rune == "Zod")
          zod++;
      }
    }
    //Dump info to txt file, if no cubing has been done.
    inline void SaveNoCube(ofstream& save,int& el, int& eld, int& tir, int& nef,
                           int& eth, int& ith, int& tal, int& ral, int& ort, int& thul,
                           int& amn, int& sol, int& shael, int& dol, int& hel, int& io,
                           int& lum, int& ko, int& fal, int& lem, int& pul, int& um,
                           int& mal, int& ist, int& gul, int& vex, int& ohm, int& lo,
                           int& sur, int& ber, int& jah, int& cham, int& zod)
    {
    
      string filename;
      cout<<"Specify path if you had to when loading."<<endl<<"Save name:"<<endl;
      getline(cin,filename);
      save.open(filename.c_str());
      if (!save.is_open())
        cout<<"The file did not open!";
      else
        save<<"Total Runes: "<<el + eld + tir + nef + eth + ith + tal + ral + ort
            + thul + amn + sol + shael + dol + hel + io + lum +
            ko + fal + lem + pul + um + mal + ist + gul + vex +
            ohm + lo + sur + ber + jah + cham + zod <<endl;
      save<<"El:" << el << "      " << "Eld:" << eld << endl << "Tir:" << tir
          << "     " << "Nef:" << nef  << endl << "Eth:" << eth << "     "
          <<"Ith:" << ith << endl << "Tal:" << tal << "     " << "Ral:" << ral
          << endl << "Ort:" << ort << "     " << "Thul:" << thul << endl << "Amn:"
          << amn << "     " << "Sol:" << sol << endl << "Shael:" << shael << "   "
          << "Dol:" << dol << endl << "Hel:" << hel << "     " << "Io:" << io
          << endl << "Lum:" << lum << "     " << "Ko:" << ko << endl << "Fal:"
          << fal << "     " << "Lem:" << lem << endl << "Pul:" << pul << "     "
          <<"Um:" << um << endl << "Mal:" << mal << "     " << "Ist:" << ist
          << endl << "Gul:" << gul << "     " << "Vex:" << vex << endl << "Ohm:"
          << ohm << "     " << "Lo:" << lo << endl << "Sur:" << sur << "     "
          << "Ber:" << ber << endl << "Jah:" << jah << "     " << "Cham:" << cham
          << endl << "Zod:" << zod <<endl;
    } //!! MISSING }
    
      inline void SaveCube(ofstream& save, int& el, int& eld, int& tir, int& nef,
                           int& eth, int& ith, int& tal, int& ral, int& ort, int& thul,
                           int& amn, int& sol, int& shael, int& dol, int& hel, int& io,
                           int& lum, int& ko, int& fal, int& lem, int& pul, int& um,
                           int& mal, int& ist, int& gul, int& vex, int& ohm, int& lo,
                           int& sur, int& ber, int& jah, int& cham, int& zod, int& el2,
                           int& eld2, int& tir2, int& nef2, int& eth2, int& ith2, int& tal2,
                           int& ral2, int& ort2, int& thul2, int& amn2, int& sol2, int& shael2,
                           int& dol2, int& hel2, int& io2, int& lum2, int& ko2, int& fal2,
                           int& lem2, int& pul2, int& um2, int& mal2, int& ist2, int& gul2,
                           int& vex2, int& ohm2, int& lo2, int& sur2, int& ber2, int& jah2,
                           int& cham2, int& zod2)
      {
        string filename;
        cout<<"Specify path if you had to when loading."<<endl<<"Save name:"<<endl;
        getline(cin,filename);
        save.open(filename.c_str());
        if (!save.is_open())
          cout<<"The file did not open!";
        else
          save<<"Total Runes: "<<el + eld + tir + nef + eth + ith + tal + ral + ort
              + thul + amn + sol + shael + dol + hel + io + lum
              + ko + fal + lem + pul + um + mal + ist + gul + vex
              + ohm + lo + sur + ber + jah + cham + zod <<endl;
    
        save<<"\nEl:" << el << "      " << "Eld:" << eld << endl << "Tir:" << tir << "     "
            << "Nef:" << nef  << endl << "Eth:" << eth << "     " << "Ith:" << ith
            << endl << "Tal:" << tal << "     " << "Ral:" << ral << endl << "Ort:" << ort
            << "     " << "Thul:" << thul << endl << "Amn:" << amn << "     " << "Sol:"
            << sol << endl << "Shael:" << shael << "   " << "Dol:" << dol << endl << "Hel:"
            << hel << "     " << "Io:" << io << endl << "Lum:" << lum << "     " << "Ko:"
            << ko << endl << "Fal:" << fal << "     " << "Lem:" << lem << endl << "Pul:"
            << pul << "     " "Um:" << um << endl << "Mal:" << mal << "     " << "Ist:"
            << ist << endl << "Gul:" << gul << "     " << "Vex:" << vex << endl << "Ohm:"
            << ohm << "     " << "Lo:" << lo << endl << "Sur:" << sur << "     " << "Ber:"
            << ber << endl << "Jah:" << jah << "     " << "Cham:" << cham << endl << "Zod:"
            << zod <<endl
            << "\nAfter cubing"<< endl
            <<"\nEl:" << el2 << "      " << "Eld:" << eld2 << endl << "Tir:" << tir2 << "     "
            << "Nef:" << nef2  << endl << "Eth:" << eth2 << "     " << "Ith:" << ith2
            << endl << "Tal:" << tal2 << "     " << "Ral:" << ral2 << endl << "Ort:" << ort2
            << "     " << "Thul:" << thul2 << endl << "Amn:" << amn2 << "     " << "Sol:"
            << sol2 << endl << "Shael:" << shael2 << "   " << "Dol:" << dol2 << endl << "Hel:"
            << hel2 << "     " << "Io:" << io2 << endl << "Lum:" << lum2 << "     " << "Ko:"
            << ko2 << endl << "Fal:" << fal2 << "     " << "Lem:" << lem2 << endl << "Pul:"
            << pul2 << "     " "Um:" << um2 << endl << "Mal:" << mal2 << "     " << "Ist:"
            << ist2 << endl << "Gul:" << gul2 << "     " << "Vex:" << vex2 << endl << "Ohm:"
            << ohm2 << "     " << "Lo:" << lo2 << endl << "Sur:" << sur2 << "     " << "Ber:"
            << ber2 << endl << "Jah:" << jah2 << "     " << "Cham:" << cham2 << endl << "Zod:"
            << zod2 <<endl;
    
      }
    //copies all the tallied up runes into another variable, used to cube so outputting both is possible
      inline void swap(int& el, int& eld, int& tir, int& nef, int& eth, int& ith,
                       int& tal, int& ral, int& ort, int& thul, int& amn, int& sol,
                       int& shael, int& dol, int& hel, int& io, int& lum, int& ko,
                       int& fal, int& lem, int& pul, int& um, int& mal, int& ist,
                       int& gul, int& vex, int& ohm, int& lo, int& sur, int& ber,
                       int& jah, int& cham, int& zod, int& el2, int& eld2,
                       int& tir2, int& nef2, int& eth2, int& ith2, int& tal2, int& ral2,
                       int& ort2, int& thul2, int& amn2, int& sol2, int& shael2,
                       int& dol2, int& hel2, int& io2, int& lum2, int& ko2, int& fal2,
                       int& lem2, int& pul2, int& um2, int& mal2, int& ist2, int& gul2,
                       int& vex2, int& ohm2, int& lo2, int& sur2, int& ber2, int& jah2,
                       int& cham2, int& zod2)
      {
        el2 = el;
        eld2 = eld;
        tir2 = tir;
        nef2 = nef;
        eth2 = eth;
        ith2 = ith;
        tal2 = tal;
        ral2 = ral;
        ort2 = ort;
        thul2 = thul;
        amn2 = amn;
        sol2 = sol;
        shael2 = shael;
        dol2 = dol;
        hel2 = hel;
        io2 = io;
        lum2 = lum;
        ko2 = ko;
        fal2 = fal;
        lem2 = lem;
        pul2 = pul;
        um2 = um;
        mal2 = mal;
        ist2 = ist;
        gul2 = gul;
        vex2 = vex;
        ohm2 = ohm;
        lo2 = lo;
        sur2 = lo;
        ber2 = ber;
        jah2 = jah;
        cham2 = cham;
        zod2 = zod;
      }
    
    
      int main ()
      {
        cout<<"Welcome to TodesRunes 1.1!"<<endl;
        int run = 1;     //menu choice
        int cubed = 0;   //if the cubing function has been called
        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; //!! MISSING ;, was comma
        int el2 = 0, eld2 = 0, tir2 = 0, nef2 = 0, eth2 = 0, ith2 = 0, tal2 = 0,
        ral2 = 0, ort2 = 0, thul2 = 0,amn2 = 0, sol2 = 0, shael2 = 0, dol2 = 0,
        hel2 = 0, io2 = 0, lum2 = 0, ko2 = 0, fal2 = 0, lem2 = 0,pul2 = 0, um2 = 0,
        mal2 = 0, ist2 = 0, gul2 = 0, vex2 = 0, ohm2 = 0, lo2 = 0, sur2 = 0, ber2 = 0,
        jah2 = 0, cham2 = 0, zod2 = 0;
            // ^^^ all the rune variables
        ifstream file;     //ATMA dump
        ofstream save;     //TodesRune dump
    
        loadfile(file);    //loads the ATMA dump
    
        counter(el, eld, tir, nef, eth, ith, tal, ral, ort, thul, amn,  //counts the runes in the dump
                sol, shael, dol, hel, io, lum, ko, fal, lem, pul, um,
                mal, ist, gul, vex, ohm, lo, sur, ber, jah, cham, zod, file);
    
    
        //outputs the total runes the console
        cout<< "There are "<<el + eld + tir + nef + eth + ith + tal + ral + ort + thul
            + amn + sol + shael + dol + hel + io + lum + ko + fal + lem + pul + um +
            mal + ist + gul + vex + ohm + lo + sur + ber + jah + cham + zod
            <<" runes that have been sorted" << endl;
        //menu
        while(run!=4)
        {
          cout<<"1. Cube all runes to the max."<<endl<<"2. Display current runes."<<
              endl<<"3. Save data to a file."<<endl<<"4. Blame Durf!!!! (quit)"<<endl<<"Choice: ";
          cin>>run;
          cin.ignore();
          switch(run)
          {
            case 1:
              swap(el, eld, tir, nef, eth, ith, tal, ral, ort, thul, amn,
                   sol, shael, dol, hel, io, lum, ko, fal, lem, pul, um,
                   mal, ist, gul, vex, ohm, lo, sur, ber, jah, cham, zod,
                   el2, eld2, tir2, nef2, eth2, ith2, tal2, ral2, ort2, thul2, amn2,
                   sol2, shael2, dol2, hel2, io2, lum2, ko2, fal2, lem2, pul2, um2,
                   mal2, ist2, gul2, vex2, ohm2, lo2, sur2, ber2, jah2, cham2, zod2);
              cube(el2, eld2, tir2, nef2, eth2, ith2, tal2, ral2, ort2, thul2, amn2,
                   sol2, shael2, dol2, hel2, io2, lum2, ko2, fal2, lem2, pul2, um2,
                   mal2, ist2, gul2, vex2, ohm2, lo2, sur2, ber2, jah2, cham2, zod2);
              cubed = 1;
              output(el2, eld2, tir2, nef2, eth2, ith2, tal2, ral2, ort2, thul2, amn2,
                     sol2, shael2, dol2, hel2, io2, lum2, ko2, fal2, lem2, pul2, um2,
                     mal2, ist2, gul2, vex2, ohm2, lo2, sur2, ber2, jah2, cham2, zod2);
              break;
            case 2:
              output(el, eld, tir, nef, eth, ith, tal, ral, ort, thul, amn,
                     sol, shael, dol, hel, io, lum, ko, fal, lem, pul, um,
                     mal, ist, gul, vex, ohm, lo, sur, ber, jah, cham, zod);
              break;
            case 3:
              //!! warning: suggest parentheses around assignment used as truth value
              if(cubed=0)
              {
                SaveNoCube(save, el, eld, tir, nef, eth, ith, tal, ral, ort, thul, amn,
                           sol, shael, dol, hel, io, lum, ko, fal, lem, pul, um,
                           mal, ist, gul, vex, ohm, lo, sur, ber, jah, cham, zod);
              }
              else
              {
                SaveCube(save, el, eld, tir, nef, eth, ith, tal, ral, ort, thul, amn,
                         sol, shael, dol, hel, io, lum, ko, fal, lem, pul, um,
                         mal, ist, gul, vex, ohm, lo, sur, ber, jah, cham, zod,
                         el2, eld2, tir2, nef2, eth2, ith2, tal2, ral2, ort2, thul2, amn2,
                         sol2, shael2, dol2, hel2, io2, lum2, ko2, fal2, lem2, pul2, um2,
                         mal2, ist2, gul2, vex2, ohm2, lo2, sur2, ber2, jah2, cham2, zod2);
              }
              break;
            default:
              cout<<"You entered an invalid response, please try agian"<<endl;
              break;
          }
        }
        return 0;
      }
    > Also any tips on making the program faster would be good also
    1. Stop making everything inline.
    2. Look into using arrays and structures - all those variables with 1,2 suffixes are just screaming to be arrays. This will significantly cut down on all those parameters.

  3. #3
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    I tried to make everything arrays, but couldn't figure out how to reference an array, from what I read, it is impossible. I am still learning to use things other than inlines. Should I try my hand at moving them into classes, or should I just make them into functions with prototypes and stuff. Also I don't understand at all what you mean by:

    Quote Originally Posted by Salem
    Find the //!! comments

  4. #4
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    Code:
    void function (int array[]);
    Sent from my iPadŽ

  5. #5
    Registered User
    Join Date
    Apr 2003
    Posts
    2,663
    I tried to make everything arrays, but couldn't figure out how to reference an array, from what I read, it is impossible.
    Code:
    include <iostream>
    using namespace std;
    
    void display(int anArray[][3], int numRows, int numColumns)
    {
    	for(int i = 0; i<numRows; i++)
    	{
    		for(int j = 0; j<numColumns; j++)
    		{
    			cout<<anArray[i][j]<<" ";
    		}
    		cout<<endl;
    	}
    }
    
    	
    int main()
    {
    	const int rows = 2;
    	const int columns = 3;
    
    	int arr[rows][columns] = 
    	{
    		{1, 2, 3},
    		{10, 20, 30}
    	};
    
    	display(arr, rows, columns);
    
    	return 0;
    }

  6. #6
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    wow I stand corrected (I am glad too). I am going to rewrite a good portion (all of it) now. Thanks!

    But, one more question, what is a better method than using inline functions? A quick example if possible, would help emensly.

    ~Wraith

  7. #7
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,079
    http://www.parashift.com/c++-faq-li...-functions.html

    There are no simple answers: You have to play with it to see what is best. Do not settle for simplistic answers like, "Never use inline functions" or "Always use inline functions" or "Use inline functions if and only if the function is less than N lines of code." These one-size-fits-all rules may be easy to write down, but they will produce sub-optimal results.
    Sent from my iPadŽ

  8. #8
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > Also I don't understand at all what you mean by:
    It tells you where the errors were

    > But, one more question, what is a better method than using inline functions?
    With the possible exception of single statement get/set functions inside classes, it's probably best not to use them at all until the program is finished. Then you can make careful experiments to determine whether inline makes any difference at all, based on some actual profiling information.

  9. #9
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    Dead link.

    But that quote is good, I still want to learn a couple other ways, I think I will hit up the FAQ on functions, also, I never really learned classes yet, but would that be a viable option?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Resources with Dev C++ Problem (many simple problems)
    By Zeusbwr in forum Windows Programming
    Replies: 4
    Last Post: 04-06-2005, 11:08 PM
  2. New to Dev C++/<windows.h>...
    By Cilius in forum C++ Programming
    Replies: 3
    Last Post: 02-23-2005, 01:05 AM
  3. Glut and Dev C++, Programs not Quitting?
    By Zeusbwr in forum Game Programming
    Replies: 13
    Last Post: 11-29-2004, 08:43 PM
  4. DEV C++ Limitations?
    By Kirdra in forum Game Programming
    Replies: 3
    Last Post: 09-09-2002, 09:40 PM
  5. Tutorial about Bloodshed Dev!
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 11-13-2001, 07:42 PM