C++ Tworzenie obiektu w funkcji

Witam. Chciałem zrobić w konsoli grę strategiczną, turową. (Na razie mam entuzjastyczne nastawienie, bo jeszcze nie dotarłem do losowego generatora mapy i inteligencji przeciwników)

Otóż chciałbym, żeby dane dotyczące krajów były wczytywanie z pliku, a kraje mają być obiektami.

No i niby wszystko jest, tylko że nie wiem, gdzie i jak utworzyć te obiekty…

Chodzi o to, że nie mogę zrobić tego w funkcji, ponieważ main nie widzi wtedy jego obiektu.

Dla testu samego wczytywania, zrobiłem taki osobny programik.

#include <iostream>
#include <cstdlib>
#include <windows.h>
#include <fstream>
#include <sstream>
#include "klasy.h"
 
using namespace std;
 
HANDLE hOut;
fstream plik;
int kraje;
string z_pliku[11];
 
void kolor(HANDLE h, string fore, string bck);
 
bool wczytaj_kraj();
 
 
int main()
{
    hOut = GetStdHandle( STD_OUTPUT_HANDLE );
 
    wczytaj_kraj();
 
    for(int i; i<kraje; i++)
    {
        cout << kraj[i].nazwa << endl;
        cout << kraj[i].skrot << endl;
        cout << endl;
        cout << kraj[i].flaga[0] << endl;
        cout << kraj[i].flaga[1] << endl;
        cout << kraj[i].flaga[2] << endl;
        cout << kraj[i].flaga[3] << endl;
        cout << kraj[i].flaga[4] << endl;
        cout << kraj[i].flaga[5] << endl;
    }
 
    return 0;
}
 
bool wczytaj_kraj()
{
    string krajuchny;
 
    plik.open("kraje/kraje.txt", ios::in);
 
    if(plik.good()==true)
    {
        getline(plik, krajuchny);
        istringstream iss(krajuchny);
        iss >> kraje;
 
        Kraj kraj[kraje];
 
        int licznik = 0;
        int licznik2 = 0;
        while(getline(plik, z_pliku[licznik]))
        {
            if(licznik==1) kraj[licznik2].nazwa = z_pliku[licznik];
            if(licznik==2) kraj[licznik2].skrot = z_pliku[licznik];
            if(licznik==3) kraj[licznik2].flaga[0] = z_pliku[licznik];
            if(licznik==4) kraj[licznik2].flaga[1] = z_pliku[licznik];
            if(licznik==5) kraj[licznik2].flaga[2] = z_pliku[licznik];
            if(licznik==6) kraj[licznik2].flaga[3] = z_pliku[licznik];
            if(licznik==7) kraj[licznik2].flaga[4] = z_pliku[licznik];
            if(licznik==8) kraj[licznik2].flaga[5] = z_pliku[licznik];
 
            if(licznik==10)
            {
                licznik = 0;
                licznik2++;
            }
 
            licznik++;
        }
 
        return true;
    }
    else
    {
        system("cls");
        kolor(hOut, "lgold", "none");
        cout << "                           ##############################" << endl;
        cout << "                           #";
        kolor(hOut, "lred", "none");
        cout <<  "Nie udalo sie wczytac krajow";
        kolor(hOut, "lgold", "none");
        cout << "#" << endl;
        cout << "                           ##############################" << endl;
 
        return false;
    }
 
}
 

void kolor(HANDLE h, string fore, string bck) //funkcja do kolorkow
{
    //TEKST
 
    //ciemne
    if((fore=="blue")&&(bck=="none")) SetConsoleTextAttribute(h, FOREGROUND_BLUE);
    if((fore=="red")&&(bck=="none")) SetConsoleTextAttribute(h, FOREGROUND_RED);
    if((fore=="green")&&(bck=="none")) SetConsoleTextAttribute(h, FOREGROUND_GREEN);
    if((fore=="cyan")&&(bck=="none")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN);
    if((fore=="violet")&&(bck=="none")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_RED);
    if((fore=="gold")&&(bck=="none")) SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_GREEN);
    if((fore=="white")&&(bck=="none")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED);
 
    //jasne
    if((fore=="lblue")&&(bck=="none")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_INTENSITY);
    if((fore=="lred")&&(bck=="none")) SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_INTENSITY);
    if((fore=="lgreen")&&(bck=="none")) SetConsoleTextAttribute(h, FOREGROUND_GREEN | FOREGROUND_INTENSITY);
    if((fore=="lcyan")&&(bck=="none")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY);
    if((fore=="lviolet")&&(bck=="none")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_INTENSITY);
    if((fore=="lgold")&&(bck=="none")) SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY);
    if((fore=="lwhite")&&(bck=="none")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY);
 
    //TLO
 
    //ciemne
    if((fore=="none")&&(bck=="blue")) SetConsoleTextAttribute(h, BACKGROUND_BLUE);
    if((fore=="none")&&(bck=="red")) SetConsoleTextAttribute(h, BACKGROUND_RED);
    if((fore=="none")&&(bck=="green")) SetConsoleTextAttribute(h, BACKGROUND_GREEN);
    if((fore=="none")&&(bck=="cyan")) SetConsoleTextAttribute(h, BACKGROUND_BLUE | BACKGROUND_GREEN);
    if((fore=="none")&&(bck=="violet")) SetConsoleTextAttribute(h, BACKGROUND_BLUE | BACKGROUND_RED);
    if((fore=="none")&&(bck=="gold")) SetConsoleTextAttribute(h, BACKGROUND_RED | BACKGROUND_GREEN);
    if((fore=="none")&&(bck=="white")) SetConsoleTextAttribute(h, BACKGROUND_BLUE | BACKGROUND_RED | BACKGROUND_GREEN);
 
    //jasne
    if((fore=="none")&&(bck=="lblue")) SetConsoleTextAttribute(h, BACKGROUND_BLUE | BACKGROUND_INTENSITY);
    if((fore=="none")&&(bck=="lred")) SetConsoleTextAttribute(h, BACKGROUND_RED | BACKGROUND_INTENSITY);
    if((fore=="none")&&(bck=="lgreen")) SetConsoleTextAttribute(h, BACKGROUND_GREEN | BACKGROUND_INTENSITY);
    if((fore=="none")&&(bck=="lcyan")) SetConsoleTextAttribute(h, BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_INTENSITY);
    if((fore=="none")&&(bck=="lviolet")) SetConsoleTextAttribute(h, BACKGROUND_BLUE | BACKGROUND_RED | BACKGROUND_INTENSITY);
    if((fore=="none")&&(bck=="lgold")) SetConsoleTextAttribute(h, BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_INTENSITY);
    if((fore=="none")&&(bck=="lwhite")) SetConsoleTextAttribute(h, BACKGROUND_BLUE | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_INTENSITY);
 
    //NIEBIESKI&TLO
 
    //ciemne
    if((fore=="blue")&&(bck=="blue")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | BACKGROUND_BLUE);
    if((fore=="blue")&&(bck=="red")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | BACKGROUND_RED);
    if((fore=="blue")&&(bck=="green")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | BACKGROUND_GREEN);
    if((fore=="blue")&&(bck=="cyan")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | BACKGROUND_BLUE | BACKGROUND_GREEN);
    if((fore=="blue")&&(bck=="violet")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | BACKGROUND_BLUE | BACKGROUND_RED);
    if((fore=="blue")&&(bck=="gold")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED);
    if((fore=="blue")&&(bck=="white")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED);
 
    //jasne
    if((fore=="blue")&&(bck=="lblue")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | BACKGROUND_BLUE | BACKGROUND_INTENSITY);
    if((fore=="blue")&&(bck=="lred")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | BACKGROUND_RED | BACKGROUND_INTENSITY);
    if((fore=="blue")&&(bck=="lgreen")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_INTENSITY);
    if((fore=="blue")&&(bck=="lcyan")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_INTENSITY);
    if((fore=="blue")&&(bck=="lviolet")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | BACKGROUND_BLUE | BACKGROUND_RED | BACKGROUND_INTENSITY);
    if((fore=="blue")&&(bck=="lgold")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY);
    if((fore=="blue")&&(bck=="lwhite")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY);
 
    //CZERWONY&TLO
 
    //ciemne
    if((fore=="red")&&(bck=="blue")) SetConsoleTextAttribute(h, FOREGROUND_RED | BACKGROUND_BLUE);
    if((fore=="red")&&(bck=="red")) SetConsoleTextAttribute(h, FOREGROUND_RED | BACKGROUND_RED);
    if((fore=="red")&&(bck=="green")) SetConsoleTextAttribute(h, FOREGROUND_RED | BACKGROUND_GREEN);
    if((fore=="red")&&(bck=="cyan")) SetConsoleTextAttribute(h, FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_GREEN);
    if((fore=="red")&&(bck=="violet")) SetConsoleTextAttribute(h, FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_RED);
    if((fore=="red")&&(bck=="gold")) SetConsoleTextAttribute(h, FOREGROUND_RED | BACKGROUND_RED | BACKGROUND_GREEN);
    if((fore=="red")&&(bck=="white")) SetConsoleTextAttribute(h, FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED);
 
    //jasne
    if((fore=="red")&&(bck=="lblue")) SetConsoleTextAttribute(h, FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_INTENSITY);
    if((fore=="red")&&(bck=="lred")) SetConsoleTextAttribute(h, FOREGROUND_RED | BACKGROUND_RED | BACKGROUND_INTENSITY);
    if((fore=="red")&&(bck=="lgreen")) SetConsoleTextAttribute(h, FOREGROUND_RED | BACKGROUND_GREEN | BACKGROUND_INTENSITY);
    if((fore=="red")&&(bck=="lcyan")) SetConsoleTextAttribute(h, FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_INTENSITY);
    if((fore=="red")&&(bck=="lviolet")) SetConsoleTextAttribute(h, FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_RED | BACKGROUND_INTENSITY);
    if((fore=="red")&&(bck=="lgold")) SetConsoleTextAttribute(h, FOREGROUND_RED | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_INTENSITY);
    if((fore=="red")&&(bck=="lwhite")) SetConsoleTextAttribute(h, FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY);
 
    //ZIELONY&TLO
 
    //ciemne
    if((fore=="green")&&(bck=="blue")) SetConsoleTextAttribute(h, FOREGROUND_GREEN | BACKGROUND_BLUE);
    if((fore=="green")&&(bck=="red")) SetConsoleTextAttribute(h, FOREGROUND_GREEN | BACKGROUND_RED);
    if((fore=="green")&&(bck=="green")) SetConsoleTextAttribute(h, FOREGROUND_GREEN | BACKGROUND_GREEN);
    if((fore=="green")&&(bck=="cyan")) SetConsoleTextAttribute(h, FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_GREEN);
    if((fore=="green")&&(bck=="violet")) SetConsoleTextAttribute(h, FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_RED);
    if((fore=="green")&&(bck=="gold")) SetConsoleTextAttribute(h, FOREGROUND_GREEN | BACKGROUND_RED | BACKGROUND_GREEN);
    if((fore=="green")&&(bck=="white")) SetConsoleTextAttribute(h, FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED);
 
    //jasne
    if((fore=="green")&&(bck=="lblue")) SetConsoleTextAttribute(h, FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_INTENSITY);
    if((fore=="green")&&(bck=="lred")) SetConsoleTextAttribute(h, FOREGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY);
    if((fore=="green")&&(bck=="lgreen")) SetConsoleTextAttribute(h, FOREGROUND_GREEN | BACKGROUND_GREEN | BACKGROUND_INTENSITY);
    if((fore=="green")&&(bck=="lcyan")) SetConsoleTextAttribute(h, FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_INTENSITY);
    if((fore=="green")&&(bck=="lviolet")) SetConsoleTextAttribute(h, FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_RED | BACKGROUND_INTENSITY);
    if((fore=="green")&&(bck=="lgold")) SetConsoleTextAttribute(h, FOREGROUND_GREEN | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_INTENSITY);
    if((fore=="green")&&(bck=="lwhite")) SetConsoleTextAttribute(h, FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY);
 
    //TURKUS&TLO
 
    //ciemne
    if((fore=="cyan")&&(bck=="blue")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | BACKGROUND_BLUE);
    if((fore=="cyan")&&(bck=="red")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | BACKGROUND_RED);
    if((fore=="cyan")&&(bck=="green")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | BACKGROUND_GREEN);
    if((fore=="cyan")&&(bck=="cyan")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_GREEN);
    if((fore=="cyan")&&(bck=="violet")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_RED);
    if((fore=="cyan")&&(bck=="gold")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | BACKGROUND_RED | BACKGROUND_GREEN);
    if((fore=="cyan")&&(bck=="white")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED);
 
    //jasne
    if((fore=="cyan")&&(bck=="lblue")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_INTENSITY);
    if((fore=="cyan")&&(bck=="lred")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY);
    if((fore=="cyan")&&(bck=="lgreen")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | BACKGROUND_GREEN | BACKGROUND_INTENSITY);
    if((fore=="cyan")&&(bck=="lcyan")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_INTENSITY);
    if((fore=="cyan")&&(bck=="lviolet")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_RED | BACKGROUND_INTENSITY);
    if((fore=="cyan")&&(bck=="lgold")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_INTENSITY);
    if((fore=="cyan")&&(bck=="lwhite")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY);
 
    //FIOLET&TLO
 
    //ciemne
    if((fore=="violet")&&(bck=="blue")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_RED | BACKGROUND_BLUE);
    if((fore=="violet")&&(bck=="red")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_RED | BACKGROUND_RED);
    if((fore=="violet")&&(bck=="green")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_RED | BACKGROUND_GREEN);
    if((fore=="violet")&&(bck=="cyan")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_GREEN);
    if((fore=="violet")&&(bck=="violet")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_RED);
    if((fore=="violet")&&(bck=="gold")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_RED | BACKGROUND_RED | BACKGROUND_GREEN);
    if((fore=="violet")&&(bck=="white")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED);
 
    //jasne
    if((fore=="violet")&&(bck=="lblue")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_INTENSITY);
    if((fore=="violet")&&(bck=="lred")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_RED | BACKGROUND_RED | BACKGROUND_INTENSITY);
    if((fore=="violet")&&(bck=="lgreen")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_RED | BACKGROUND_GREEN | BACKGROUND_INTENSITY);
    if((fore=="violet")&&(bck=="lcyan")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_INTENSITY);
    if((fore=="violet")&&(bck=="lviolet")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_RED | BACKGROUND_INTENSITY);
    if((fore=="violet")&&(bck=="lgold")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_RED | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_INTENSITY);
    if((fore=="violet")&&(bck=="lwhite")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY);
 
    //ZLOTY&TLO
 
    //ciemne
    if((fore=="gold")&&(bck=="blue")) SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_GREEN | BACKGROUND_BLUE);
    if((fore=="gold")&&(bck=="red")) SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_GREEN | BACKGROUND_RED);
    if((fore=="gold")&&(bck=="green")) SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_GREEN | BACKGROUND_GREEN);
    if((fore=="gold")&&(bck=="cyan")) SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_GREEN);
    if((fore=="gold")&&(bck=="violet")) SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_RED);
    if((fore=="gold")&&(bck=="gold")) SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_GREEN | BACKGROUND_RED | BACKGROUND_GREEN);
    if((fore=="gold")&&(bck=="white")) SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED);
 
    //jasne
    if((fore=="gold")&&(bck=="lblue")) SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_INTENSITY);
    if((fore=="gold")&&(bck=="lred")) SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY);
    if((fore=="gold")&&(bck=="lgreen")) SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_GREEN | BACKGROUND_GREEN | BACKGROUND_INTENSITY);
    if((fore=="gold")&&(bck=="lcyan")) SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_INTENSITY);
    if((fore=="gold")&&(bck=="lviolet")) SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_RED | BACKGROUND_INTENSITY);
    if((fore=="gold")&&(bck=="lgold")) SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_GREEN | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_INTENSITY);
    if((fore=="gold")&&(bck=="lwhite")) SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY);
 
    //BIALY&TLO
 
    //ciemne
    if((fore=="white")&&(bck=="blue")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | BACKGROUND_BLUE);
    if((fore=="white")&&(bck=="red")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | BACKGROUND_RED);
    if((fore=="white")&&(bck=="green")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | BACKGROUND_GREEN);
    if((fore=="white")&&(bck=="cyan")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_GREEN);
    if((fore=="white")&&(bck=="violet")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_RED);
    if((fore=="white")&&(bck=="gold")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | BACKGROUND_RED | BACKGROUND_GREEN);
    if((fore=="white")&&(bck=="white")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED);
 
    //jasne
    if((fore=="white")&&(bck=="lblue")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_INTENSITY);
    if((fore=="white")&&(bck=="lred")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | BACKGROUND_RED | BACKGROUND_INTENSITY);
    if((fore=="white")&&(bck=="lgreen")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | BACKGROUND_GREEN | BACKGROUND_INTENSITY);
    if((fore=="white")&&(bck=="lcyan")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_INTENSITY);
    if((fore=="white")&&(bck=="lviolet")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_RED | BACKGROUND_INTENSITY);
    if((fore=="white")&&(bck=="lgold")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_INTENSITY);
    if((fore=="white")&&(bck=="lwhite")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY);
 
    //JASNY NIEBIESKI&TLO
 
    //ciemne
    if((fore=="lblue")&&(bck=="blue")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | BACKGROUND_BLUE | FOREGROUND_INTENSITY);
    if((fore=="lblue")&&(bck=="red")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | BACKGROUND_RED | FOREGROUND_INTENSITY);
    if((fore=="lblue")&&(bck=="green")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | BACKGROUND_GREEN | FOREGROUND_INTENSITY);
    if((fore=="lblue")&&(bck=="cyan")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | BACKGROUND_BLUE | BACKGROUND_GREEN | FOREGROUND_INTENSITY);
    if((fore=="lblue")&&(bck=="violet")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | BACKGROUND_BLUE | BACKGROUND_RED | FOREGROUND_INTENSITY);
    if((fore=="lblue")&&(bck=="gold")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | FOREGROUND_INTENSITY);
    if((fore=="lblue")&&(bck=="white")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | FOREGROUND_INTENSITY);
 
    //jasne
    if((fore=="lblue")&&(bck=="lblue")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | BACKGROUND_BLUE | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lblue")&&(bck=="lred")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | BACKGROUND_RED | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lblue")&&(bck=="lgreen")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lblue")&&(bck=="lcyan")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lblue")&&(bck=="lviolet")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | BACKGROUND_BLUE | BACKGROUND_RED | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lblue")&&(bck=="lgold")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lblue")&&(bck=="lwhite")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
 
    //JASNY CZERWONY&TLO
 
    //ciemne
    if((fore=="lred")&&(bck=="blue")) SetConsoleTextAttribute(h, FOREGROUND_RED | BACKGROUND_BLUE | FOREGROUND_INTENSITY);
    if((fore=="lred")&&(bck=="red")) SetConsoleTextAttribute(h, FOREGROUND_RED | BACKGROUND_RED | FOREGROUND_INTENSITY);
    if((fore=="lred")&&(bck=="green")) SetConsoleTextAttribute(h, FOREGROUND_RED | BACKGROUND_GREEN | FOREGROUND_INTENSITY);
    if((fore=="lred")&&(bck=="cyan")) SetConsoleTextAttribute(h, FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_GREEN | FOREGROUND_INTENSITY);
    if((fore=="lred")&&(bck=="violet")) SetConsoleTextAttribute(h, FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_RED | FOREGROUND_INTENSITY);
    if((fore=="lred")&&(bck=="gold")) SetConsoleTextAttribute(h, FOREGROUND_RED | BACKGROUND_RED | BACKGROUND_GREEN | FOREGROUND_INTENSITY);
    if((fore=="lred")&&(bck=="white")) SetConsoleTextAttribute(h, FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | FOREGROUND_INTENSITY);
 
    //jasne
    if((fore=="lred")&&(bck=="lblue")) SetConsoleTextAttribute(h, FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lred")&&(bck=="lred")) SetConsoleTextAttribute(h, FOREGROUND_RED | BACKGROUND_RED | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lred")&&(bck=="lgreen")) SetConsoleTextAttribute(h, FOREGROUND_RED | BACKGROUND_GREEN | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lred")&&(bck=="lcyan")) SetConsoleTextAttribute(h, FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lred")&&(bck=="lviolet")) SetConsoleTextAttribute(h, FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_RED | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lred")&&(bck=="lgold")) SetConsoleTextAttribute(h, FOREGROUND_RED | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lred")&&(bck=="lwhite")) SetConsoleTextAttribute(h, FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
 
    //JASNY ZIELONY&TLO
 
    //ciemne
    if((fore=="lgreen")&&(bck=="blue")) SetConsoleTextAttribute(h, FOREGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY);
    if((fore=="lgreen")&&(bck=="red")) SetConsoleTextAttribute(h, FOREGROUND_GREEN | BACKGROUND_RED | FOREGROUND_INTENSITY);
    if((fore=="lgreen")&&(bck=="green")) SetConsoleTextAttribute(h, FOREGROUND_GREEN | BACKGROUND_GREEN | FOREGROUND_INTENSITY);
    if((fore=="lgreen")&&(bck=="cyan")) SetConsoleTextAttribute(h, FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_GREEN | FOREGROUND_INTENSITY);
    if((fore=="lgreen")&&(bck=="violet")) SetConsoleTextAttribute(h, FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_RED | FOREGROUND_INTENSITY);
    if((fore=="lgreen")&&(bck=="gold")) SetConsoleTextAttribute(h, FOREGROUND_GREEN | BACKGROUND_RED | BACKGROUND_GREEN | FOREGROUND_INTENSITY);
    if((fore=="lgreen")&&(bck=="white")) SetConsoleTextAttribute(h, FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | FOREGROUND_INTENSITY);
 
    //jasne
    if((fore=="lgreen")&&(bck=="lblue")) SetConsoleTextAttribute(h, FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lgreen")&&(bck=="lred")) SetConsoleTextAttribute(h, FOREGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lgreen")&&(bck=="lgreen")) SetConsoleTextAttribute(h, FOREGROUND_GREEN | BACKGROUND_GREEN | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lgreen")&&(bck=="lcyan")) SetConsoleTextAttribute(h, FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lgreen")&&(bck=="lviolet")) SetConsoleTextAttribute(h, FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_RED | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lgreen")&&(bck=="lgold")) SetConsoleTextAttribute(h, FOREGROUND_GREEN | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lgreen")&&(bck=="lwhite")) SetConsoleTextAttribute(h, FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
 
    //JASNY TURKUS&TLO
 
    //ciemne
    if((fore=="lcyan")&&(bck=="blue")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY);
    if((fore=="lcyan")&&(bck=="red")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | BACKGROUND_RED | FOREGROUND_INTENSITY);
    if((fore=="lcyan")&&(bck=="green")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | BACKGROUND_GREEN | FOREGROUND_INTENSITY);
    if((fore=="lcyan")&&(bck=="cyan")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_GREEN | FOREGROUND_INTENSITY);
    if((fore=="lcyan")&&(bck=="violet")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_RED | FOREGROUND_INTENSITY);
    if((fore=="lcyan")&&(bck=="gold")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | BACKGROUND_RED | BACKGROUND_GREEN | FOREGROUND_INTENSITY);
    if((fore=="lcyan")&&(bck=="white")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | FOREGROUND_INTENSITY);
 
    //jasne
    if((fore=="lcyan")&&(bck=="lblue")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lcyan")&&(bck=="lred")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lcyan")&&(bck=="lgreen")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | BACKGROUND_GREEN | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lcyan")&&(bck=="lcyan")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lcyan")&&(bck=="lviolet")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_RED | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lcyan")&&(bck=="lgold")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lcyan")&&(bck=="lwhite")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
 
    //JASNY FIOLET&TLO
 
    //ciemne
    if((fore=="lviolet")&&(bck=="blue")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_RED | BACKGROUND_BLUE | FOREGROUND_INTENSITY);
    if((fore=="lviolet")&&(bck=="red")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_RED | BACKGROUND_RED | FOREGROUND_INTENSITY);
    if((fore=="lviolet")&&(bck=="green")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_RED | BACKGROUND_GREEN | FOREGROUND_INTENSITY);
    if((fore=="lviolet")&&(bck=="cyan")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_GREEN | FOREGROUND_INTENSITY);
    if((fore=="lviolet")&&(bck=="violet")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_RED | FOREGROUND_INTENSITY);
    if((fore=="lviolet")&&(bck=="gold")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_RED | BACKGROUND_RED | BACKGROUND_GREEN | FOREGROUND_INTENSITY);
    if((fore=="lviolet")&&(bck=="white")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | FOREGROUND_INTENSITY);
 
    //jasne
    if((fore=="lviolet")&&(bck=="lblue")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lviolet")&&(bck=="lred")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_RED | BACKGROUND_RED | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lviolet")&&(bck=="lgreen")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_RED | BACKGROUND_GREEN | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lviolet")&&(bck=="lcyan")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lviolet")&&(bck=="lviolet")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_RED | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lviolet")&&(bck=="lgold")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_RED | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lviolet")&&(bck=="lwhite")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
 
    //JASNY ZLOTY&TLO
 
    //ciemne
    if((fore=="lgold")&&(bck=="blue")) SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_GREEN | BACKGROUND_BLUE | FOREGROUND_INTENSITY);
    if((fore=="lgold")&&(bck=="red")) SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_GREEN | BACKGROUND_RED | FOREGROUND_INTENSITY);
    if((fore=="lgold")&&(bck=="green")) SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_GREEN | BACKGROUND_GREEN | FOREGROUND_INTENSITY);
    if((fore=="lgold")&&(bck=="cyan")) SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_GREEN | FOREGROUND_INTENSITY);
    if((fore=="lgold")&&(bck=="violet")) SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_RED | FOREGROUND_INTENSITY);
    if((fore=="lgold")&&(bck=="gold")) SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_GREEN | BACKGROUND_RED | BACKGROUND_GREEN | FOREGROUND_INTENSITY);
    if((fore=="lgold")&&(bck=="white")) SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | FOREGROUND_INTENSITY);
 
    //jasne
    if((fore=="lgold")&&(bck=="lblue")) SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lgold")&&(bck=="lred")) SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lgold")&&(bck=="lgreen")) SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_GREEN | BACKGROUND_GREEN | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lgold")&&(bck=="lcyan")) SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lgold")&&(bck=="lviolet")) SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_RED | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lgold")&&(bck=="lgold")) SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_GREEN | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lgold")&&(bck=="lwhite")) SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
 
    //JASNY BIALY&TLO
 
    //ciemne
    if((fore=="lwhite")&&(bck=="blue")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | BACKGROUND_BLUE | FOREGROUND_INTENSITY);
    if((fore=="lwhite")&&(bck=="red")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | BACKGROUND_RED | FOREGROUND_INTENSITY);
    if((fore=="lwhite")&&(bck=="green")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | BACKGROUND_GREEN | FOREGROUND_INTENSITY);
    if((fore=="lwhite")&&(bck=="cyan")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_GREEN | FOREGROUND_INTENSITY);
    if((fore=="lwhite")&&(bck=="violet")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_RED | FOREGROUND_INTENSITY);
    if((fore=="lwhite")&&(bck=="gold")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | BACKGROUND_RED | BACKGROUND_GREEN | FOREGROUND_INTENSITY);
    if((fore=="lwhite")&&(bck=="white")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | FOREGROUND_INTENSITY);
 
    //jasne
    if((fore=="lwhite")&&(bck=="lblue")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lwhite")&&(bck=="lred")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | BACKGROUND_RED | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lwhite")&&(bck=="lgreen")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | BACKGROUND_GREEN | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lwhite")&&(bck=="lcyan")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lwhite")&&(bck=="lviolet")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_RED | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lwhite")&&(bck=="lgold")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
    if((fore=="lwhite")&&(bck=="lwhite")) SetConsoleTextAttribute(h, FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED | BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY | FOREGROUND_INTENSITY);
 
}

Jeszcze plik z państwami, dla ciekawskich (litery będą później zamienione na kolory)

(wiem, flagi Wielkiej Brytanii i Stanów Zjednoczonych to masakra)

10
   Polska   
PL
wwwwwwwwwwwwwww
wwwwwwwwwwwwwww
wwwwwwwwwwwwwww
rrrrrrrrrrrrrrr
rrrrrrrrrrrrrrr
rrrrrrrrrrrrrrr
#
#
Wlk Brytania
GB
bbbwwbwrwbbwwbb
wwwwwwwrwwwwwww
rrrrrrrrrrrrrrr
wwwwwwwrwwwwwww
bbbbbwwrwwbbbbb
bbbwwbwrwbwwbbb
#
#
    Rosja   
RU
wwwwwwwwwwwwwww
wwwwwwwwwwwwwww
bbbbbbbbbbbbbbb
bbbbbbbbbbbbbbb
rrrrrrrrrrrrrrr
rrrrrrrrrrrrrrr
#
#
   Niemcy   
DE
---------------
---------------
rrrrrrrrrrrrrrr
rrrrrrrrrrrrrrr
yyyyyyyyyyyyyyy
yyyyyyyyyyyyyyy
#
#
   Francja  
FR
bbbbbwwwwwrrrrr
bbbbbwwwwwrrrrr
bbbbbwwwwwrrrrr
bbbbbwwwwwrrrrr
bbbbbwwwwwrrrrr
bbbbbwwwwwrrrrr
#
#
     USA    
US
wbwbwbwwwwwwwww
bwbwbwrrrrrrrrr
wbwbwbwwwwwwwww
rrrrrrrrrrrrrrr
wwwwwwwwwwwwwww
rrrrrrrrrrrrrrr
#
#
   Ukraina  
UA
sssssssssssssss
sssssssssssssss
sssssssssssssss
yyyyyyyyyyyyyyy
yyyyyyyyyyyyyyy
yyyyyyyyyyyyyyy
#
#
   Litwa   
LT
yyyyyyyyyyyyyyy
yyyyyyyyyyyyyyy
ggggggggggggggg
ggggggggggggggg
rrrrrrrrrrrrrrr
rrrrrrrrrrrrrrr
#
#
   Wlochy   
IT
gggggwwwwwrrrrr
gggggwwwwwrrrrr
gggggwwwwwrrrrr
gggggwwwwwrrrrr
gggggwwwwwrrrrr
gggggwwwwwrrrrr
#
#
   Wietnam  
VN
rrrrrrrrrrrrrrr
rrrrrrryrrrrrrr
rrrrryyyyyrrrrr
rrrrrryyyrrrrrr
rrrrrrryrrrrrrr
rrrrrrrrrrrrrrr

Po pierwsze: https://pl-pl.facebook.com/programistaplakaljakcommitowal

Nie za bardzo rozumiem, po co dawałeś ten pierwszy link, natomiast w drugim nic nie znalazłem.

A tak jakoś… słyszałem, że poszukują programistów do kalkulatora PKW 2.0 - jest nadzieja

 

 

Bo ogólnie, to trzeba umieć szukać. Nazywa się to zwracaniem obiektu przez wskaźnik.

No faktycznie trzeba. Widać ja nie umiem. W każdym razie znalazłem to w końcu, tylko jest problem.

 

Wskaźnik musi być globalny. Ilość krajów jest z założenia nieznana, znajduje się ona dopiero w pliku.

Nie mogę stworzyć globalnych wskaźników w ilości kraje, bo ta zmienna zapełnia się dopiero w funkcji.

Poczytaj o strukturach zwanych kontenerami.

:arrow: http://pl.wikipedia.org/wiki/Kontener_(programowanie) http://cpp0x.pl/dokumentacja/standard-C++/Adaptery-i-kontenery/18 http://asawicki.info/productions/artykuly/strukturyd_formatyp.php5 http://www.cplusplus.com/reference/stl/

Jeśli nie wiesz jaki kontener wybrać, wybierz vector :wink:

Nie za bardzo rozumiem, jak to połączyć ze zwracaniem obiektu przez wskaźnik…

Jeśli funkcja wczytuje po jednym elemencie, to wywołujesz ją w pętli, a zwracane wskaźniki wrzucasz do wektora, dopóki nie skończą się elementy (co możesz sygnalizować np. zwróceniem NULLa z funkcji wczytującej).

Jeśli funkcja wczytuje wszystkie elementy, to możesz zwrócić z niej wektor wskaźników albo (zazwyczaj lepiej) wektor obiektów.

Trochę inwencji :wink:

Cóż, jest to dobrym dowodem, iż będzie ze mnie słaby programista. Jakkolwiek wciąż będę przeć na przód.

Zacznij od skrócenia kodu, bo to co masz to istna masakra.

Mówisz o tej funkcji do kolorów, czy o całym kodzie?

 

EDIT a, no i wciąż nie rozumiem, jak mam to zwrócić…

Nie wałkuje się X razy tego samego, te kolory można by wrzucić jako przykład jak nie pisać programów.

Te stałe to możesz je sobie dowolnie zamieniać i łączyć.

Zamiast walić wszystkie możliwe kombinacje zrób 1 switcha i będziesz miał i 3/4 krócej.

Co do samego zwracania, pewnie nie przeczytałeś nic o wektorze, nie wiesz co to return ? przykład:

#include <iostream>
#include <vector>
using namespace std;

class k{
public:
	int x;
	int y;
	int z;

	k(int wx, int wy, int wz){
		x=wx;
		y=wy;
		z=wz;
	}
};
vector<k> f(){
	vector<k>uklad;
	uklad.push_back(k(1,1,1));
	uklad.push_back(k(2,2,2));
return uklad;
}
int main(){
	vector<k> uklad = f();

	for(vector<k>::iterator i = uklad.begin();i != uklad.end(); ++i)
	cout << i->x<< i->y<< i->z <<endl;

	cin.sync();
	cin.get();
	return 0;
}

Napisałem ten program mniej więcej tak: (z kolorami nic nie wymyśliłem więc wziąłem rozwiązanie mniej więcej z internetu)

#include <iostream>
#include <cstdlib>
#include <windows.h>
#include <fstream>
#include <sstream>
#include <vector>
#include "klasy.h"
 
using namespace std;
 
fstream plik;
int kraje;
string z_pliku[11];
bool wczytano = false;
 
 
void kolor(string fore, string bck);
 
vector<Kraj> wczytaj_kraj();
 
 
int main()
{
    vector<Kraj> kraj = wczytaj_kraj();
 
    if(wczytano==true)
    {
        for(int i; i<kraje; i++)
        {
            cout << kraj[i].nazwa << endl;
            cout << kraj[i].skrot << endl;
            cout << endl;
            cout << kraj[i].flaga[0] << endl;
            cout << kraj[i].flaga[1] << endl;
            cout << kraj[i].flaga[2] << endl;
            cout << kraj[i].flaga[3] << endl;
            cout << kraj[i].flaga[4] << endl;
            cout << kraj[i].flaga[5] << endl;
        }
 
    }
        return 0;
}
 
vector<Kraj> wczytaj_kraj()
{
    string krajuchny;
 
    plik.open("kraje/kraje.txt", ios::in);
 
    if(plik.good()==true)
    {
        getline(plik, krajuchny);
        istringstream iss(krajuchny);
        iss >> kraje;
 
        Kraj krajy[kraje];
 
        vector < Kraj > kraj;
 
        for(int i=0; i<kraje; i++)
        {
            kraj.push_back( krajy[i] );
        }
 
        int licznik = 0;
        int licznik2 = 0;
        while(getline(plik, z_pliku[licznik]))
        {
            if(licznik==1) kraj[licznik2].nazwa = z_pliku[licznik];
            if(licznik==2) kraj[licznik2].skrot = z_pliku[licznik];
            if(licznik==3) kraj[licznik2].flaga[0] = z_pliku[licznik];
            if(licznik==4) kraj[licznik2].flaga[1] = z_pliku[licznik];
            if(licznik==5) kraj[licznik2].flaga[2] = z_pliku[licznik];
            if(licznik==6) kraj[licznik2].flaga[3] = z_pliku[licznik];
            if(licznik==7) kraj[licznik2].flaga[4] = z_pliku[licznik];
            if(licznik==8) kraj[licznik2].flaga[5] = z_pliku[licznik];
 
            if(licznik==10)
            {
                licznik = 0;
                licznik2++;
            }
 
            licznik++;
        }
        wczytano = true;
 
        return kraj;
    }
    else
    {
        system("cls");
        kolor("lgold", "none");
        cout << "                           ##############################" << endl;
        cout << "                           #";
        kolor("lred", "none");
        cout <<  "Nie udalo sie wczytac krajow";
        kolor("lgold", "none");
        cout << "#" << endl;
        cout << "                           ##############################" << endl;
 
        //to żeby program się nie crashował, jeśli nie uda się wczytać
        kraje = 1;
        Kraj krajenz;
        vector < Kraj > kraj;
        kraj.push_back( krajenz );
 
        return kraj;
    }
 
}
 
void kolor(string fore, string bck) //funkcja do kolorkow
{
    HANDLE h;
    h = GetStdHandle( STD_OUTPUT_HANDLE );
 
    int tekst=0, tlo=0;
 
    if(fore=="blue")   tekst = 1;
    if(fore=="green")  tekst = 2;
    if(fore=="cyan")   tekst = 3;
    if(fore=="red")    tekst = 4;
    if(fore=="violet") tekst = 5;
    if(fore=="gold") tekst = 6;
    if(fore=="white")  tekst = 7;
 
    if(fore=="gray") tekst = 8;
 
    if(fore=="lblue")   tekst = 9;
    if(fore=="lgreen")  tekst = 10;
    if(fore=="lcyan")   tekst = 11;
    if(fore=="lred")    tekst = 12;
    if(fore=="lviolet") tekst = 13;
    if(fore=="lgold") tekst = 14;
    if(fore=="lwhite")  tekst = 15;
 
 
    if(bck=="blue")   tlo = 1;
    if(bck=="green")  tlo = 2;
    if(bck=="cyan")   tlo = 3;
    if(bck=="red")    tlo = 4;
    if(bck=="violet") tlo = 5;
    if(bck=="gold") tlo = 6;
    if(bck=="white")  tlo = 7;
 
    if(bck=="gray") tlo = 8;
 
    if(bck=="lblue")   tlo = 9;
    if(bck=="lgreen")  tlo = 10;
    if(bck=="lcyan")   tlo = 11;
    if(bck=="lred")    tlo = 12;
    if(bck=="lviolet") tlo = 13;
    if(bck=="lgold") tlo = 14;
    if(bck=="lwhite")  tlo = 15;
 
    SetConsoleTextAttribute(h, tekst+16*tlo);
}

Ale nic się nie pokazuje.

Oczywiście poza sytuacją, w której zmienię nazwę folderu z plikiem, wtedy mam informację, że nie udało się wczytać krajów. :wink:

Nie zainicjalizowałeś zmiennej i, więc ma ona nieokreśloną wartość. Powinno być

for(int i = 0; i < kraje; i++)

W kwestii szukania błędów polecam http://www.youtube.com/playlist?list=PL5D59D2682ED5B2EA :wink:

Zamiast wrzucać w pętli puste obiekty do wektora, możesz od razu stworzyć wektor o odpowiednim rozmiarze

vector<Kraj> kraj(kraje);

Cóż, działa, ale jest inny problem.

Po skompilowaniu tego kodu:

#include <iostream>
#include <cstdlib>
#include <windows.h>
#include <fstream>
#include <sstream>
#include <vector>
#include "klasy.h"
 
using namespace std;
 
fstream plik;
int kraje;
string z_pliku[11];
bool wczytano = false;
 
 
void kolor(string fore, string bck);
 
vector<Kraj> wczytaj_kraj();
 
 
int main()
{
    vector<Kraj> kraj = wczytaj_kraj();
 
    if(wczytano==true)
    {
        for(int i=0; i<kraje; i++)
        {
            cout << "nazwa:" <<kraj[i].nazwa << endl;
            cout << "skrot:" << kraj[i].skrot << endl;
            cout << endl << "flaga:" << endl;
            cout << kraj[i].flaga[0] << endl;
            cout << kraj[i].flaga[1] << endl;
            cout << kraj[i].flaga[2] << endl;
            cout << kraj[i].flaga[3] << endl;
            cout << kraj[i].flaga[4] << endl;
            cout << kraj[i].flaga[5] << endl << endl;
        }
 
    }
        return 0;
}
 
vector<Kraj> wczytaj_kraj()
{
    string krajuchny;
 
    plik.open("kraje/kraje.txt", ios::in);
 
    if(plik.good()==true)
    {
        getline(plik, krajuchny);
        istringstream iss(krajuchny);
        iss >> kraje;
 
        vector < Kraj > kraj(kraje);
 
        int licznik = 0;
        int licznik2 = 0;
        while(getline(plik, z_pliku[licznik]))
        {
            if(licznik==0) kraj[licznik2].nazwa = z_pliku[licznik];
            if(licznik==1) kraj[licznik2].skrot = z_pliku[licznik];
            if(licznik==2) kraj[licznik2].flaga[0] = z_pliku[licznik];
            if(licznik==3) kraj[licznik2].flaga[1] = z_pliku[licznik];
            if(licznik==4) kraj[licznik2].flaga[2] = z_pliku[licznik];
            if(licznik==5) kraj[licznik2].flaga[3] = z_pliku[licznik];
            if(licznik==6) kraj[licznik2].flaga[4] = z_pliku[licznik];
            if(licznik==7) kraj[licznik2].flaga[5] = z_pliku[licznik];
 
            if(licznik==10)
            {
                licznik = 0;
                licznik2++;
            }
            licznik++;
        }
        wczytano = true;
 
        return kraj;
    }
    else
    {
        system("cls");
        kolor("lgold", "none");
        cout << "                           ##############################" << endl;
        cout << "                           #";
        kolor("lred", "none");
        cout <<  "Nie udalo sie wczytac krajow";
        kolor("lgold", "none");
        cout << "#" << endl;
        cout << "                           ##############################" << endl;
 
        //to zeby program sie nie crashowal, jesli nie uda sie wczytac
        kraje = 1;
        Kraj krajenz;
        vector < Kraj > kraj;
        kraj.push_back( krajenz );
 
        return kraj;
    }
}
 
void kolor(string fore, string bck) //funkcja do kolorkow
{
    HANDLE h;
    h = GetStdHandle( STD_OUTPUT_HANDLE );
 
    int tekst=0, tlo=0;
 
    if(fore=="blue")   tekst = 1;
    if(fore=="green")  tekst = 2;
    if(fore=="cyan")   tekst = 3;
    if(fore=="red")    tekst = 4;
    if(fore=="violet") tekst = 5;
    if(fore=="gold") tekst = 6;
    if(fore=="white")  tekst = 7;
 
    if(fore=="gray") tekst = 8;
 
    if(fore=="lblue")   tekst = 9;
    if(fore=="lgreen")  tekst = 10;
    if(fore=="lcyan")   tekst = 11;
    if(fore=="lred")    tekst = 12;
    if(fore=="lviolet") tekst = 13;
    if(fore=="lgold") tekst = 14;
    if(fore=="lwhite")  tekst = 15;
 
 
    if(bck=="blue")   tlo = 1;
    if(bck=="green")  tlo = 2;
    if(bck=="cyan")   tlo = 3;
    if(bck=="red")    tlo = 4;
    if(bck=="violet") tlo = 5;
    if(bck=="gold") tlo = 6;
    if(bck=="white")  tlo = 7;
 
    if(bck=="gray") tlo = 8;
 
    if(bck=="lblue")   tlo = 9;
    if(bck=="lgreen")  tlo = 10;
    if(bck=="lcyan")   tlo = 11;
    if(bck=="lred")    tlo = 12;
    if(bck=="lviolet") tlo = 13;
    if(bck=="lgold") tlo = 14;
    if(bck=="lwhite")  tlo = 15;
 
    SetConsoleTextAttribute(h, tekst+16*tlo);
}

 

Dla rozwiania wątpliwości podam też .h i .cpp klasy:

//.h
#include <iostream>
 
using namespace std;
 
class Kraj
{
    public:
 
    string nazwa;
    string skrot;
    string flaga[6];
 
    Kraj();
};
 

//.cpp
#include <iostream>
#include "klasy.h"
 
using namespace std;
 
//############################
//{########Klasa Kraj#########
//############################
 
Kraj::Kraj()
{
    nazwa = "------------";
    skrot = "--";
    flaga[0] = "lglglglglglglgl";
    flaga[1] = "glglglglglglglg";
    flaga[2] = "lglglglglglglgl";
    flaga[3] = "glglglglglglglg";
    flaga[4] = "lglglglglglglgl";
    flaga[5] = "glglglglglglglg";
}
 
//############################
//}###########################
//############################

 

Otrzymuję takie wyjście:

 

http://oi58.tinypic.com/2zsn2aw.jpg

 

 

Jak widać, nie wszystkie dane się wczytują.

Dodam, że chociaż raczej nie tu leży problem, bo dane nie są poprzestawiane tylko ich nie ma, to gdy w kawałku:

if(licznik==10)
{
    licznik = 0; //tutaj
    licznik2++;
}
licznik++;

Zamienię 0 na cokolwiek innego (nawet mniejszego), program zawiesza się.

Każdy kiedyś zaczynał, masz tu przykład jak to się robi w C++ (aby ci nie mieszać w głowie używam tylko C++98)

 

plik main.cpp:

#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include "country.h"

const size_t flag_size = 6;


void skip_line(std::ifstream & file)
{
int c;

	do
	{
		c = file.get();
	}
	while( c != '\n' && c != EOF );
}


void read_country(std::ifstream & file, Country & country)
{
std::string flag;

	country.clear();
	std::getline(file, country.name);
	std::getline(file, country.short_name);

	for(size_t f = 0 ; f < flag_size ; ++f)
	{
		std::getline(file, flag);
		country.flag.push_back(flag);
	}

	std::getline(file, flag); // skipping two lines with '#' character
	std::getline(file, flag);
}


bool read_countries(const char * file_name, std::vector<Country> & countries_tab)
{
size_t country_size;
Country country;

	countries_tab.clear();
	std::ifstream file(file_name, std::ios_base::in);

	if( !file )
	{
		std::cout << "I cannot read from: " << file_name << std::endl;
		return false;
	}

	file >> country_size;
	skip_line(file);

	for(size_t c = 0 ; c < country_size ; ++c)
	{
		read_country(file, country);
		countries_tab.push_back(country);
	}

return true;
}


void print_countries(const std::vector<Country> & countries_tab)
{
	for(size_t i=0 ; i<countries_tab.size() ; ++i)
	{
		const Country & c = countries_tab[i];

		std::cout << c.name << std::endl;
		std::cout << c.short_name << std::endl;

		for(size_t f=0 ; f<c.flag.size() ; ++f)
			std::cout << c.flag[f] << std::endl;
	}
}


int main()
{
std::vector<Country> countries_tab;

	if( read_countries("kraje.txt", countries_tab) )
		print_countries(countries_tab);
}

oraz country.h:

#ifndef headerfile_country
#define headerfile_country

#include <string>
#include <vector>


struct Country
{
	std::string name;
	std::string short_name;
	std::vector<std::string> flag;

	void clear()
	{
		name.clear();
		short_name.clear();
		flag.clear();
	}
};


#endif

Plik wejściowy jest taki jaki podałeś w pierwszym poście, swoją drogą nie wiem po co ci tam te linie ze znakami ‘#’. Nie używam kolorków bo nie widzę w jaki sposób drukujesz z kolorami te flagi ani nie mam pod ręką windowsa aby to sprawdzić.

Obawiam się, że nie zrozumiałem dużej części tego kodu…

Więc powinieneś się trochę poduczyć :wink:

Polecam http://gynvael.coldwind.pl/?id=238, http://www.intercon.pl/~sektor/cbx/ i http://xion.org.pl/productions/texts/coding/megatutorial/; dodatkowo możesz przeczytać http://gynvael.coldwind.pl/?id=374, http://gynvael.coldwind.pl/?id=408, http://asawicki.info/productions/artykuly/strukturyd_formatyp.php5 i http://www.uw-team.org/forum/viewtopic.php?f=7&t=9751&p=77955#p77955.

Miłej zabawy :smiley:

Faktycznie moja wiedza była (i wciąż jest) pełna dziur, jednak teraz liczbę tych dziur zmniejszyłem.

 

Twój kod był w znacznym stopniu zrozumiały, jednak mam trudności z rozumieniem nieswojego kodu i zwaliłem winę na parę znanych mi znaczków, zapisywanych inaczej, niż ja to robię. (z większą ilością spacji na przykład)

W tej chwili spróbuję zrozumieć ten kod i użyć tych rozwiązań we własnym. (nauczę się ich, oraz nie będę miał do czynienia z niemoim kodem w moim kodzie)

 

Jakkolwiek definitywnie nie rozumiałem, czym i po co są użyte przez ciebie dyrektywy preprocesora.

Ale wciąż niezbyt tu jedną rzecz rozumiem…

Po co ci to?

#ifndef headerfile_country
#define headerfile_country
 
(...)
 
#endif

Rozumiem już, do czego taki zapis służy, jednak nie rozumiem, jakie ma mieć zastosowanie w tym miejscu…

 

EDIT

Aha, no i  po co stworzyłeś funkcję skip_line(), skoro (chyba) nigdzie jej nie używasz?

Tutaj chodzi o to by przy przyłączaniu kolejnego pliku (z tym samym nagłówkiem) nie wrzucać tego kodu drugi raz.

W twoim przypadku (o ile będziesz miał include tylko w jednym pliku) problemu nie będzie. Jednak taki zapis bardzo pomaga, tym bardziej że kod od tego nie rośnie.

 

A skipline, wywala zbędne entery z pliku.