When I try to save variable to two dimensional array, it saves it in two dimensions [0] [1] instead of one.
For example:
dodajDoKolejki(1,1)
// Adding numer 1 to dimension 1priting array gives me result shown below, but it shouldn't change kolejka[0]
kolejka[0] = 0 0 1 0 0 0 0 0 0 kolejka[1] = 1 0 0 0 0 0 0 0 0
int (*kolejka)[2]; // Global variable
...
int queue[2][ilSamochodow+1];
kolejka = &queue;
...
void dodajDoKolejki(int numerWatku,int miasto)
//Adding numbers from 1-... to random dimensions (given as miasto)
{
//Checking if number already exists( int istnieje ) in array
int istnieje = 0;
int i;
for(i=0;i<ilSamochodow+1;i++)
{
if(kolejka[miasto][i] == numerWatku)
istnieje = 1;
}
if(istnieje == 0)
{
//Looking for 0 in array, if found we can save on its index( == 0)
i = 0; // Indeks miejsca, w ktorym zapiszemy numerWatku
while(kolejka[miasto][i] != 0)
i++;
kolejka[miasto][i] = numerWatku;
printf("\nDodano %d do kolejki miasta %d",numerWatku,miasto);
wypiszKolejke2(miasto);
}
else
printf("\nBlad. Nie mozna dodac, poniewaz watek jest w kolejce!");
}