string go(string s, int& ind, node* cur,char &c)
{
string f = "";
if (cur->leftChild == NULL && cur->rightChild == NULL)
{
f = cur-> content;
}
else
{
if (s[ind] == 0x30)
{
ind++;
go(s, ind, cur->leftChild,c);
}
else
{
ind++;
go(s, ind, cur->rightChild,c);
}
}
return f;// breakpoint here shows correct value 'e'
}
...
int main()
{
string h = "";
int ind = 0;
string h = go(s, ind, &glob_root,c);
cout << h << endl; // h is blank.
}
Turns out, that first time breakpoint on f hits, it shows value as 'e', what I want, but then it gets blank the following times it's hit.
if I change it to
string go(string s, int& ind, node* cur,char &c)
{
if (cur->leftChild == NULL && cur->rightChild == NULL)
{
return cur-> content;
}
else
{
if (s[ind] == 0x30)
{
ind++;
go(s, ind, cur->leftChild,c);
}
else
{
ind++;
go(s, ind, cur->rightChild,c);
}
}
}
I get an access violation, since I have no return, If i add return ""; at the end, it just returns nothing, not 'e'
Any help appreciated
f = go(...)(I guess).