I have two funcions
int zapiszGenotyp(genotyp *p, int dlugoscGenotypu, int genDoWpisania)
{
if (!p)
{
genotyp *nowy = new genotyp;
nowy->pNext = 0;
p = nowy;
nowy->gen = genDoWpisania;
dlugoscGenotypu++;
}
else if (p->pNext == 0)
{
genotyp *nowy = new genotyp;
nowy->pNext = 0;
p->pNext = nowy;
nowy->gen = genDoWpisania;
dlugoscGenotypu++;
}
else
zapiszGenotyp(p->pNext, dlugoscGenotypu, genDoWpisania);
return dlugoscGenotypu;
}
void stworzListeOsobnikow(osobnicy *& p, ifstream & input)
{
while (input)
{
if (p==0)
{
p = new osobnicy;
string linia;
getline(input, linia);
istringstream strumien(linia);
int gen;
while (strumien >> gen)
{
p->dlugoscDNA = zapiszGenotyp(p->pGeny, 0, gen);
}
p->pNext = 0;
double(*wybraneDopasowanie)(genotyp*);
wybraneDopasowanie = dopasowanie1;
p->dopasowanie = wybraneDopasowanie(p->pGeny);
}
else if (p->pNext == 0)
{
osobnicy *nowy = new osobnicy;
string linia;
getline(input, linia);
istringstream strumien(linia);
int gen;
while (strumien >> gen)
{
nowy->dlugoscDNA=zapiszGenotyp(nowy->pGeny, 0, gen);
}
nowy->pNext = 0;
p->pNext = nowy;
double(*wybraneDopasowanie)(genotyp*);
wybraneDopasowanie = dopasowanie1;
p->dopasowanie = wybraneDopasowanie(p->pGeny);
}
else
stworzListeOsobnikow(p->pNext, input);
}
And they use following structures
struct genotyp
{
genotyp * pNext;
int gen;
};
struct osobnicy
{
osobnicy * pNext;
genotyp * pGeny;
int dlugoscDNA;
double dopasowanie;
};
When I try to run then code it stops on when the stworzListeOsobnikow() runs the zapiszGenotyp(). I've realised that pointer passed to zapiszGenotyp() as genotyp *p is always CDCDCDCD but i have no idea what it means. Just using p->pNext in zapiszGenotyp() crashes the program. Could anyone explain to me what is this CDCDCDCD pointer, and what seem to be wrong with my code?